Skip to content

Commit cfc1274

Browse files
authored
Disable IE innerHTML workaround behind a flag (#26390)
We don't need this workaround for SVG anymore and we don't need to workaround MSApp's security model since Windows 10.
1 parent a57f40d commit cfc1274

12 files changed

+27
-3
lines changed

packages/react-dom-bindings/src/client/ReactDOMComponent.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
enableCustomElementPropertySupport,
7575
enableClientRenderFallbackOnTextMismatch,
7676
enableHostSingletons,
77+
disableIEWorkarounds,
7778
} from 'shared/ReactFeatureFlags';
7879
import {
7980
mediaEventTypes,
@@ -116,7 +117,8 @@ if (__DEV__) {
116117
// normalized. Since it only affects IE, we're skipping style warnings
117118
// in that browser completely in favor of doing all that work.
118119
// See https://github.com/facebook/react/issues/11807
119-
canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode;
120+
canDiffStyleForHydrationWarning =
121+
disableIEWorkarounds || (canUseDOM && !document.documentMode);
120122
}
121123

122124
function validatePropertiesInDevelopment(type: string, props: any) {
@@ -308,7 +310,11 @@ function setInitialDOMProperties(
308310
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
309311
const nextHtml = nextProp ? nextProp[HTML] : undefined;
310312
if (nextHtml != null) {
311-
setInnerHTML(domElement, nextHtml);
313+
if (disableIEWorkarounds) {
314+
domElement.innerHTML = nextHtml;
315+
} else {
316+
setInnerHTML(domElement, nextHtml);
317+
}
312318
}
313319
} else if (propKey === CHILDREN) {
314320
if (typeof nextProp === 'string') {
@@ -366,7 +372,11 @@ function updateDOMProperties(
366372
if (propKey === STYLE) {
367373
setValueForStyles(domElement, propValue);
368374
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
369-
setInnerHTML(domElement, propValue);
375+
if (disableIEWorkarounds) {
376+
domElement.innerHTML = propValue;
377+
} else {
378+
setInnerHTML(domElement, propValue);
379+
}
370380
} else if (propKey === CHILDREN) {
371381
setTextContent(domElement, propValue);
372382
} else {

packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ describe('ReactDOMServerHydration', () => {
195195
);
196196
});
197197

198+
// @gate !disableIEWorkarounds || !__DEV__
198199
it('should not warn when the style property differs on whitespace or order in IE', () => {
199200
document.documentMode = 11;
200201
jest.resetModules();

packages/react-dom/src/client/__tests__/dangerouslySetInnerHTML-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('dangerouslySetInnerHTML', () => {
5555
);
5656
});
5757

58+
// @gate !disableIEWorkarounds
5859
it('sets innerHTML on it', () => {
5960
const html = '<circle></circle>';
6061
const container = document.createElementNS(
@@ -69,6 +70,7 @@ describe('dangerouslySetInnerHTML', () => {
6970
expect(circle.tagName).toBe('circle');
7071
});
7172

73+
// @gate !disableIEWorkarounds
7274
it('clears previous children', () => {
7375
const firstHtml = '<rect></rect>';
7476
const secondHtml = '<circle></circle>';

packages/react-dom/src/client/__tests__/trustedTypes-test.internal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ describe('when Trusted Types are available in global object', () => {
208208
);
209209
});
210210

211+
// @gate !disableIEWorkarounds
211212
it('should log a warning', () => {
212213
class Component extends React.Component {
213214
render() {

packages/shared/ReactFeatureFlags.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ export const enableTrustedTypesIntegration = false;
169169
// DOM properties
170170
export const disableInputAttributeSyncing = false;
171171

172+
// Remove IE and MsApp specific workarounds for innerHTML
173+
export const disableIEWorkarounds = __EXPERIMENTAL__;
174+
172175
// Filter certain DOM attributes (e.g. src, href) if their values are empty
173176
// strings. This prevents e.g. <img src=""> from making an unnecessary HTTP
174177
// request for certain browsers.

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const debugRenderPhaseSideEffectsForStrictMode = true;
3636
export const disableJavaScriptURLs = false;
3737
export const disableCommentsAsDOMContainers = true;
3838
export const disableInputAttributeSyncing = false;
39+
export const disableIEWorkarounds = true;
3940
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
4041
export const enableScopeAPI = false;
4142
export const enableCreateEventHandleAPI = false;

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const enableFetchInstrumentation = false;
2626
export const disableJavaScriptURLs = false;
2727
export const disableCommentsAsDOMContainers = true;
2828
export const disableInputAttributeSyncing = false;
29+
export const disableIEWorkarounds = true;
2930
export const enableSchedulerDebugging = false;
3031
export const enableScopeAPI = false;
3132
export const enableCreateEventHandleAPI = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const enableFetchInstrumentation = true;
2626
export const disableJavaScriptURLs = false;
2727
export const disableCommentsAsDOMContainers = true;
2828
export const disableInputAttributeSyncing = false;
29+
export const disableIEWorkarounds = true;
2930
export const enableSchedulerDebugging = false;
3031
export const enableScopeAPI = false;
3132
export const enableCreateEventHandleAPI = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const enableFetchInstrumentation = false;
2626
export const disableJavaScriptURLs = false;
2727
export const disableCommentsAsDOMContainers = true;
2828
export const disableInputAttributeSyncing = false;
29+
export const disableIEWorkarounds = true;
2930
export const enableSchedulerDebugging = false;
3031
export const enableScopeAPI = false;
3132
export const enableCreateEventHandleAPI = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const enableSchedulerDebugging = false;
2727
export const disableJavaScriptURLs = false;
2828
export const disableCommentsAsDOMContainers = true;
2929
export const disableInputAttributeSyncing = false;
30+
export const disableIEWorkarounds = true;
3031
export const enableScopeAPI = true;
3132
export const enableCreateEventHandleAPI = false;
3233
export const enableSuspenseCallback = true;

packages/shared/forks/ReactFeatureFlags.www-dynamic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// with the __VARIANT__ set to `true`, and once set to `false`.
1515

1616
export const disableInputAttributeSyncing = __VARIANT__;
17+
export const disableIEWorkarounds = __VARIANT__;
1718
export const enableFilterEmptyStringAttributesDOM = __VARIANT__;
1819
export const enableLegacyFBSupport = __VARIANT__;
1920
export const skipUnmountedBoundaries = __VARIANT__;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const dynamicFeatureFlags: DynamicFeatureFlags = require('ReactFeatureFlags');
1616

1717
export const {
1818
disableInputAttributeSyncing,
19+
disableIEWorkarounds,
1920
enableTrustedTypesIntegration,
2021
disableSchedulerTimeoutBasedOnReactExpirationTime,
2122
replayFailedUnitOfWorkWithInvokeGuardedCallback,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy