@@ -8,54 +8,54 @@ import parseStyleName from './parseStyleName';
88import generateAppendClassName from './generateAppendClassName' ;
99
1010const linkElement = ( element : ReactElement , styles : Object , configuration : Object ) : ReactElement => {
11- let appendClassName ,
12- elementIsFrozen ,
13- elementShallowCopy ;
11+ let appendClassName ,
12+ elementIsFrozen ,
13+ elementShallowCopy ;
1414
15- elementShallowCopy = element ;
15+ elementShallowCopy = element ;
1616
17- if ( Object . isFrozen && Object . isFrozen ( elementShallowCopy ) ) {
18- elementIsFrozen = true ;
17+ if ( Object . isFrozen && Object . isFrozen ( elementShallowCopy ) ) {
18+ elementIsFrozen = true ;
1919
2020 // https://github.com/facebook/react/blob/v0.13.3/src/classic/element/ReactElement.js#L131
21- elementShallowCopy = objectUnfreeze ( elementShallowCopy ) ;
22- elementShallowCopy . props = objectUnfreeze ( elementShallowCopy . props ) ;
23- }
21+ elementShallowCopy = objectUnfreeze ( elementShallowCopy ) ;
22+ elementShallowCopy . props = objectUnfreeze ( elementShallowCopy . props ) ;
23+ }
2424
25- const styleNames = parseStyleName ( elementShallowCopy . props . styleName || '' , configuration . allowMultiple ) ;
25+ const styleNames = parseStyleName ( elementShallowCopy . props . styleName || '' , configuration . allowMultiple ) ;
2626
27- if ( React . isValidElement ( elementShallowCopy . props . children ) ) {
28- elementShallowCopy . props . children = linkElement ( React . Children . only ( elementShallowCopy . props . children ) , styles , configuration ) ;
29- } else if ( _ . isArray ( elementShallowCopy . props . children ) || isIterable ( elementShallowCopy . props . children ) ) {
30- elementShallowCopy . props . children = React . Children . map ( elementShallowCopy . props . children , ( node ) => {
31- if ( React . isValidElement ( node ) ) {
32- return linkElement ( node , styles , configuration ) ;
33- } else {
34- return node ;
35- }
36- } ) ;
37- }
27+ if ( React . isValidElement ( elementShallowCopy . props . children ) ) {
28+ elementShallowCopy . props . children = linkElement ( React . Children . only ( elementShallowCopy . props . children ) , styles , configuration ) ;
29+ } else if ( _ . isArray ( elementShallowCopy . props . children ) || isIterable ( elementShallowCopy . props . children ) ) {
30+ elementShallowCopy . props . children = React . Children . map ( elementShallowCopy . props . children , ( node ) => {
31+ if ( React . isValidElement ( node ) ) {
32+ return linkElement ( node , styles , configuration ) ;
33+ } else {
34+ return node ;
35+ }
36+ } ) ;
37+ }
3838
39- if ( styleNames . length ) {
40- appendClassName = generateAppendClassName ( styles , styleNames , configuration . errorWhenNotFound ) ;
39+ if ( styleNames . length ) {
40+ appendClassName = generateAppendClassName ( styles , styleNames , configuration . errorWhenNotFound ) ;
4141
42- if ( appendClassName ) {
43- if ( elementShallowCopy . props . className ) {
44- appendClassName = elementShallowCopy . props . className + ' ' + appendClassName ;
45- }
42+ if ( appendClassName ) {
43+ if ( elementShallowCopy . props . className ) {
44+ appendClassName = elementShallowCopy . props . className + ' ' + appendClassName ;
45+ }
4646
47- elementShallowCopy . props . className = appendClassName ;
48- }
47+ elementShallowCopy . props . className = appendClassName ;
4948 }
49+ }
5050
51- delete elementShallowCopy . props . styleName ;
51+ delete elementShallowCopy . props . styleName ;
5252
53- if ( elementIsFrozen ) {
54- Object . freeze ( elementShallowCopy . props ) ;
55- Object . freeze ( elementShallowCopy ) ;
56- }
53+ if ( elementIsFrozen ) {
54+ Object . freeze ( elementShallowCopy . props ) ;
55+ Object . freeze ( elementShallowCopy ) ;
56+ }
5757
58- return elementShallowCopy ;
58+ return elementShallowCopy ;
5959} ;
6060
6161/**
@@ -65,9 +65,9 @@ const linkElement = (element: ReactElement, styles: Object, configuration: Objec
6565 */
6666export default ( element : ReactElement , styles = { } , configuration = { } ) : ReactElement => {
6767 // @see https://github.com/gajus/react-css-modules/pull/30
68- if ( ! _ . isObject ( element ) ) {
69- return element ;
70- }
68+ if ( ! _ . isObject ( element ) ) {
69+ return element ;
70+ }
7171
72- return linkElement ( element , styles , configuration ) ;
72+ return linkElement ( element , styles , configuration ) ;
7373} ;
0 commit comments