@@ -11,25 +11,25 @@ let linkElement;
11
11
linkElement = ( element , styles , configuration ) => {
12
12
let appendClassName ,
13
13
elementIsFrozen ,
14
- clonedElement ,
15
- newChildren ,
16
- newProps ,
14
+ elementShallowCopy ,
17
15
styleNames ;
18
16
19
- if ( Object . isFrozen && Object . isFrozen ( element ) ) {
17
+ elementShallowCopy = element ;
18
+
19
+ if ( Object . isFrozen && Object . isFrozen ( elementShallowCopy ) ) {
20
20
elementIsFrozen = true ;
21
21
22
22
// https://github.com/facebook/react/blob/v0.13.3/src/classic/element/ReactElement.js#L131
23
- element = objectUnfreeze ( element ) ;
24
- element . props = objectUnfreeze ( element . props ) ;
23
+ elementShallowCopy = objectUnfreeze ( elementShallowCopy ) ;
24
+ elementShallowCopy . props = objectUnfreeze ( elementShallowCopy . props ) ;
25
25
}
26
26
27
- styleNames = parseStyleName ( element . props . styleName || '' , configuration . allowMultiple ) ;
27
+ styleNames = parseStyleName ( elementShallowCopy . props . styleName || '' , configuration . allowMultiple ) ;
28
28
29
- if ( React . isValidElement ( element . props . children ) ) {
30
- element . props . children = linkElement ( React . Children . only ( element . props . children ) , styles , configuration ) ;
31
- } else if ( _ . isArray ( element . props . children ) || isIterable ( element . props . children ) ) {
32
- element . props . children = React . Children . map ( element . props . children , ( node ) => {
29
+ if ( React . isValidElement ( elementShallowCopy . props . children ) ) {
30
+ elementShallowCopy . props . children = linkElement ( React . Children . only ( elementShallowCopy . props . children ) , styles , configuration ) ;
31
+ } else if ( _ . isArray ( elementShallowCopy . props . children ) || isIterable ( elementShallowCopy . props . children ) ) {
32
+ elementShallowCopy . props . children = React . Children . map ( elementShallowCopy . props . children , ( node ) => {
33
33
if ( React . isValidElement ( node ) ) {
34
34
return linkElement ( node , styles , configuration ) ;
35
35
} else {
@@ -41,20 +41,20 @@ linkElement = (element, styles, configuration) => {
41
41
if ( styleNames . length ) {
42
42
appendClassName = generateAppendClassName ( styles , styleNames , configuration . errorWhenNotFound ) ;
43
43
44
- if ( element . props . className ) {
45
- appendClassName = element . props . className + ' ' + appendClassName ;
44
+ if ( elementShallowCopy . props . className ) {
45
+ appendClassName = elementShallowCopy . props . className + ' ' + appendClassName ;
46
46
}
47
47
48
- element . props . className = appendClassName ;
49
- element . props . styleName = null ;
48
+ elementShallowCopy . props . className = appendClassName ;
49
+ elementShallowCopy . props . styleName = null ;
50
50
}
51
51
52
52
if ( elementIsFrozen ) {
53
- Object . freeze ( element ) ;
54
- Object . freeze ( element . props ) ;
53
+ Object . freeze ( elementShallowCopy . props ) ;
54
+ Object . freeze ( elementShallowCopy ) ;
55
55
}
56
56
57
- return element ;
57
+ return elementShallowCopy ;
58
58
} ;
59
59
60
60
/**
0 commit comments