@@ -67,6 +67,7 @@ let warnForTextDifference;
6767let warnForPropDifference ;
6868let warnForExtraAttributes ;
6969let warnForInvalidEventListener ;
70+ let canDiffStyleForHydrationWarning ;
7071
7172let normalizeMarkupForTextOrAttribute ;
7273let normalizeHTML ;
@@ -94,6 +95,16 @@ if (__DEV__) {
9495 validateUnknownProperties ( type , props , /* canUseEventSystem */ true ) ;
9596 } ;
9697
98+ // IE 11 parses & normalizes the style attribute as opposed to other
99+ // browsers. It adds spaces and sorts the properties in some
100+ // non-alphabetical order. Handling that would require sorting CSS
101+ // properties in the client & server versions or applying
102+ // `expectedStyle` to a temporary DOM node to read its `style` attribute
103+ // normalized. Since it only affects IE, we're skipping style warnings
104+ // in that browser completely in favor of doing all that work.
105+ // See https://github.com/facebook/react/issues/11807
106+ canDiffStyleForHydrationWarning = ! document . documentMode ;
107+
97108 // HTML parsing normalizes CR and CRLF to LF.
98109 // It also can turn \u0000 into \uFFFD inside attributes.
99110 // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
@@ -1000,15 +1011,7 @@ export function diffHydratedProperties(
10001011 // $FlowFixMe - Should be inferred as not undefined.
10011012 extraAttributeNames . delete ( propKey ) ;
10021013
1003- // IE 11 parses & normalizes the style attribute as opposed to other
1004- // browsers. It adds spaces and sorts the properties in some
1005- // non-alphabetical order. Handling that would require sorting CSS
1006- // properties in the client & server versions or applying
1007- // `expectedStyle` to a temporary DOM node to read its `style` attribute
1008- // normalized. Since it only affects IE, we're skipping style warnings
1009- // in that browser completely in favor of doing all that work.
1010- // See https://github.com/facebook/react/issues/11807
1011- if ( ! document . documentMode ) {
1014+ if ( canDiffStyleForHydrationWarning ) {
10121015 const expectedStyle = CSSPropertyOperations . createDangerousStringForStyles (
10131016 nextProp ,
10141017 ) ;
0 commit comments