@@ -82,14 +82,6 @@ import {
82
82
let didWarnInvalidHydration = false ;
83
83
let didWarnScriptTags = false ;
84
84
85
- const DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML' ;
86
- const SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning' ;
87
- const SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning' ;
88
- const AUTOFOCUS = 'autoFocus' ;
89
- const CHILDREN = 'children' ;
90
- const STYLE = 'style' ;
91
- const HTML = '__html' ;
92
-
93
85
let warnedUnknownTags : {
94
86
[ key : string ] : boolean ,
95
87
} ;
@@ -296,7 +288,7 @@ function setInitialDOMProperties(
296
288
}
297
289
const nextProp = nextProps [ propKey ] ;
298
290
switch ( propKey ) {
299
- case STYLE : {
291
+ case ' style ' : {
300
292
if ( __DEV__ ) {
301
293
if ( nextProp ) {
302
294
// Freeze the next style object so that we can assume it won't be
@@ -308,8 +300,8 @@ function setInitialDOMProperties(
308
300
setValueForStyles ( domElement , nextProp ) ;
309
301
break ;
310
302
}
311
- case DANGEROUSLY_SET_INNER_HTML : {
312
- const nextHtml = nextProp ? nextProp [ HTML ] : undefined ;
303
+ case ' dangerouslySetInnerHTML ' : {
304
+ const nextHtml = nextProp ? nextProp . __html : undefined ;
313
305
if ( nextHtml != null ) {
314
306
if ( disableIEWorkarounds ) {
315
307
domElement . innerHTML = nextHtml ;
@@ -319,7 +311,7 @@ function setInitialDOMProperties(
319
311
}
320
312
break ;
321
313
}
322
- case CHILDREN : {
314
+ case 'children' : {
323
315
if ( typeof nextProp === 'string' ) {
324
316
// Avoid setting initial textContent when the text is empty. In IE11 setting
325
317
// textContent on a <textarea> will cause the placeholder to not
@@ -348,15 +340,15 @@ function setInitialDOMProperties(
348
340
}
349
341
break ;
350
342
}
351
- case SUPPRESS_CONTENT_EDITABLE_WARNING :
352
- case SUPPRESS_HYDRATION_WARNING :
343
+ case ' suppressContentEditableWarning ' :
344
+ case ' suppressHydrationWarning ' :
353
345
case 'defaultValue ': // Reserved
354
346
case 'defaultChecked ':
355
347
case 'innerHTML ': {
356
348
// Noop
357
349
break ;
358
350
}
359
- case AUTOFOCUS : {
351
+ case ' autoFocus ' : {
360
352
// We polyfill it separately on the client during commit.
361
353
// We could have excluded it in the property list instead of
362
354
// adding a special case here, but then it wouldn't be emitted
@@ -728,7 +720,7 @@ export function diffProperties(
728
720
continue ;
729
721
}
730
722
switch ( propKey ) {
731
- case STYLE : {
723
+ case 'style' : {
732
724
const lastStyle = lastProps [ propKey ] ;
733
725
for ( styleName in lastStyle ) {
734
726
if ( lastStyle . hasOwnProperty ( styleName ) ) {
@@ -740,20 +732,20 @@ export function diffProperties(
740
732
}
741
733
break ;
742
734
}
743
- case DANGEROUSLY_SET_INNER_HTML :
744
- case CHILDREN : {
735
+ case 'dangerouslySetInnerHTML' :
736
+ case 'children' : {
745
737
// Noop. This is handled by the clear text mechanism.
746
738
break ;
747
739
}
748
- case SUPPRESS_CONTENT_EDITABLE_WARNING :
749
- case SUPPRESS_HYDRATION_WARNING :
740
+ case 'suppressContentEditableWarning' :
741
+ case 'suppressHydrationWarning' :
750
742
case 'defaultValue' : // Reserved
751
743
case 'defaultChecked' :
752
744
case 'innerHTML' : {
753
745
// Noop
754
746
break ;
755
747
}
756
- case AUTOFOCUS : {
748
+ case 'autoFocus' : {
757
749
// Noop. It doesn't work on updates anyway.
758
750
break ;
759
751
}
@@ -790,7 +782,7 @@ export function diffProperties(
790
782
continue ;
791
783
}
792
784
switch ( propKey ) {
793
- case STYLE : {
785
+ case ' style ' : {
794
786
if ( __DEV__ ) {
795
787
if ( nextProp ) {
796
788
// Freeze the next style object so that we can assume it won't be
@@ -835,9 +827,9 @@ export function diffProperties(
835
827
}
836
828
break ;
837
829
}
838
- case DANGEROUSLY_SET_INNER_HTML : {
839
- const nextHtml = nextProp ? nextProp [ HTML ] : undefined ;
840
- const lastHtml = lastProp ? lastProp [ HTML ] : undefined ;
830
+ case 'dangerouslySetInnerHTML' : {
831
+ const nextHtml = nextProp ? nextProp . __html : undefined ;
832
+ const lastHtml = lastProp ? lastProp . __html : undefined ;
841
833
if ( nextHtml != null ) {
842
834
if ( lastHtml !== nextHtml ) {
843
835
( updatePayload = updatePayload || [ ] ) . push ( propKey , nextHtml ) ;
@@ -848,7 +840,7 @@ export function diffProperties(
848
840
}
849
841
break ;
850
842
}
851
- case CHILDREN : {
843
+ case ' children ' : {
852
844
if ( typeof nextProp === 'string' || typeof nextProp === 'number' ) {
853
845
( updatePayload = updatePayload || [ ] ) . push ( propKey , '' + nextProp ) ;
854
846
}
@@ -870,15 +862,15 @@ export function diffProperties(
870
862
}
871
863
break ;
872
864
}
873
- case SUPPRESS_CONTENT_EDITABLE_WARNING :
874
- case SUPPRESS_HYDRATION_WARNING :
865
+ case 'suppressContentEditableWarning' :
866
+ case 'suppressHydrationWarning' :
875
867
case 'defaultValue' : // Reserved
876
868
case 'defaultChecked' :
877
869
case 'innerHTML' : {
878
870
// Noop
879
871
break;
880
872
}
881
- case AUTOFOCUS : {
873
+ case 'autoFocus' : {
882
874
// Noop on updates
883
875
break;
884
876
}
@@ -912,9 +904,9 @@ export function diffProperties(
912
904
}
913
905
if ( styleUpdates ) {
914
906
if ( __DEV__ ) {
915
- validateShorthandPropertyCollisionInDev ( styleUpdates , nextProps [ STYLE ] ) ;
907
+ validateShorthandPropertyCollisionInDev ( styleUpdates , nextProps . style ) ;
916
908
}
917
- ( updatePayload = updatePayload || [ ] ) . push ( STYLE , styleUpdates ) ;
909
+ ( updatePayload = updatePayload || [ ] ) . push ( 'style' , styleUpdates ) ;
918
910
}
919
911
return updatePayload ;
920
912
}
@@ -1000,32 +992,32 @@ function diffHydratedCustomComponent(
1000
992
}
1001
993
continue ;
1002
994
}
1003
- if ( rawProps [ SUPPRESS_HYDRATION_WARNING ] === true ) {
995
+ if ( rawProps . suppressHydrationWarning === true ) {
1004
996
// Don't bother comparing. We're ignoring all these warnings.
1005
997
continue ;
1006
998
}
1007
999
// Validate that the properties correspond to their expected values.
1008
1000
let serverValue ;
1009
1001
switch ( propKey ) {
1010
- case CHILDREN : // Checked above already
1011
- case SUPPRESS_CONTENT_EDITABLE_WARNING :
1012
- case SUPPRESS_HYDRATION_WARNING :
1002
+ case 'children' : // Checked above already
1003
+ case 'suppressContentEditableWarning' :
1004
+ case 'suppressHydrationWarning' :
1013
1005
case 'defaultValue' :
1014
1006
case 'defaultChecked' :
1015
1007
case 'innerHTML' :
1016
1008
// Noop
1017
1009
continue ;
1018
- case DANGEROUSLY_SET_INNER_HTML :
1010
+ case 'dangerouslySetInnerHTML' :
1019
1011
const serverHTML = domElement . innerHTML ;
1020
- const nextHtml = nextProp ? nextProp [ HTML ] : undefined ;
1012
+ const nextHtml = nextProp ? nextProp . __html : undefined ;
1021
1013
if ( nextHtml != null ) {
1022
1014
const expectedHTML = normalizeHTML ( domElement , nextHtml ) ;
1023
1015
if ( expectedHTML !== serverHTML ) {
1024
1016
warnForPropDifference ( propKey , serverHTML , expectedHTML ) ;
1025
1017
}
1026
1018
}
1027
1019
continue ;
1028
- case STYLE :
1020
+ case 'style' :
1029
1021
// $FlowFixMe - Should be inferred as not undefined.
1030
1022
extraAttributeNames . delete ( propKey ) ;
1031
1023
@@ -1103,16 +1095,16 @@ function diffHydratedGenericElement(
1103
1095
}
1104
1096
continue ;
1105
1097
}
1106
- if ( rawProps [ SUPPRESS_HYDRATION_WARNING ] === true ) {
1098
+ if ( rawProps . suppressHydrationWarning === true ) {
1107
1099
// Don't bother comparing. We're ignoring all these warnings.
1108
1100
continue ;
1109
1101
}
1110
1102
// Validate that the properties correspond to their expected values.
1111
1103
let serverValue ;
1112
1104
switch ( propKey ) {
1113
- case CHILDREN : // Checked above already
1114
- case SUPPRESS_CONTENT_EDITABLE_WARNING :
1115
- case SUPPRESS_HYDRATION_WARNING :
1105
+ case ' children ' : // Checked above already
1106
+ case ' suppressContentEditableWarning ' :
1107
+ case ' suppressHydrationWarning ' :
1116
1108
case 'value ': // Controlled attributes are not validated
1117
1109
case 'checked ': // TODO: Only ignore them on controlled tags.
1118
1110
case 'selected ':
@@ -1121,17 +1113,17 @@ function diffHydratedGenericElement(
1121
1113
case 'innerHTML ':
1122
1114
// Noop
1123
1115
continue ;
1124
- case DANGEROUSLY_SET_INNER_HTML :
1116
+ case ' dangerouslySetInnerHTML ' :
1125
1117
const serverHTML = domElement . innerHTML ;
1126
- const nextHtml = nextProp ? nextProp [ HTML ] : undefined ;
1118
+ const nextHtml = nextProp ? nextProp . __html : undefined ;
1127
1119
if ( nextHtml != null ) {
1128
1120
const expectedHTML = normalizeHTML ( domElement , nextHtml ) ;
1129
1121
if ( expectedHTML !== serverHTML ) {
1130
1122
warnForPropDifference ( propKey , serverHTML , expectedHTML ) ;
1131
1123
}
1132
1124
}
1133
1125
continue ;
1134
- case STYLE :
1126
+ case ' style ' :
1135
1127
// $FlowFixMe - Should be inferred as not undefined.
1136
1128
extraAttributeNames . delete ( propKey ) ;
1137
1129
@@ -1292,7 +1284,7 @@ export function diffHydratedProperties(
1292
1284
// TODO: Should we use domElement.firstChild.nodeValue to compare?
1293
1285
if ( typeof children === 'string' || typeof children === 'number' ) {
1294
1286
if ( domElement . textContent !== '' + children ) {
1295
- if ( rawProps [ SUPPRESS_HYDRATION_WARNING ] !== true ) {
1287
+ if ( rawProps . suppressHydrationWarning !== true ) {
1296
1288
checkForUnmatchedText (
1297
1289
domElement . textContent ,
1298
1290
children ,
@@ -1301,7 +1293,7 @@ export function diffHydratedProperties(
1301
1293
) ;
1302
1294
}
1303
1295
if ( ! isConcurrentMode ) {
1304
- updatePayload = [ CHILDREN , children ] ;
1296
+ updatePayload = [ 'children' , children ] ;
1305
1297
}
1306
1298
}
1307
1299
}
@@ -1346,7 +1338,7 @@ export function diffHydratedProperties(
1346
1338
if (
1347
1339
// $FlowFixMe - Should be inferred as not undefined.
1348
1340
extraAttributeNames . size > 0 &&
1349
- rawProps [ SUPPRESS_HYDRATION_WARNING ] !== true
1341
+ rawProps . suppressHydrationWarning !== true
1350
1342
) {
1351
1343
// $FlowFixMe - Should be inferred as not undefined.
1352
1344
warnForExtraAttributes ( extraAttributeNames ) ;
0 commit comments