mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
+13
-3
@@ -74,6 +74,7 @@ import {
|
||||
enableCustomElementPropertySupport,
|
||||
enableClientRenderFallbackOnTextMismatch,
|
||||
enableHostSingletons,
|
||||
disableIEWorkarounds,
|
||||
} from 'shared/ReactFeatureFlags';
|
||||
import {
|
||||
mediaEventTypes,
|
||||
@@ -116,7 +117,8 @@ if (__DEV__) {
|
||||
// normalized. Since it only affects IE, we're skipping style warnings
|
||||
// in that browser completely in favor of doing all that work.
|
||||
// See https://github.com/facebook/react/issues/11807
|
||||
canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode;
|
||||
canDiffStyleForHydrationWarning =
|
||||
disableIEWorkarounds || (canUseDOM && !document.documentMode);
|
||||
}
|
||||
|
||||
function validatePropertiesInDevelopment(type: string, props: any) {
|
||||
@@ -308,7 +310,11 @@ function setInitialDOMProperties(
|
||||
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
||||
const nextHtml = nextProp ? nextProp[HTML] : undefined;
|
||||
if (nextHtml != null) {
|
||||
setInnerHTML(domElement, nextHtml);
|
||||
if (disableIEWorkarounds) {
|
||||
domElement.innerHTML = nextHtml;
|
||||
} else {
|
||||
setInnerHTML(domElement, nextHtml);
|
||||
}
|
||||
}
|
||||
} else if (propKey === CHILDREN) {
|
||||
if (typeof nextProp === 'string') {
|
||||
@@ -366,7 +372,11 @@ function updateDOMProperties(
|
||||
if (propKey === STYLE) {
|
||||
setValueForStyles(domElement, propValue);
|
||||
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
||||
setInnerHTML(domElement, propValue);
|
||||
if (disableIEWorkarounds) {
|
||||
domElement.innerHTML = propValue;
|
||||
} else {
|
||||
setInnerHTML(domElement, propValue);
|
||||
}
|
||||
} else if (propKey === CHILDREN) {
|
||||
setTextContent(domElement, propValue);
|
||||
} else {
|
||||
|
||||
@@ -195,6 +195,7 @@ describe('ReactDOMServerHydration', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// @gate !disableIEWorkarounds || !__DEV__
|
||||
it('should not warn when the style property differs on whitespace or order in IE', () => {
|
||||
document.documentMode = 11;
|
||||
jest.resetModules();
|
||||
|
||||
@@ -55,6 +55,7 @@ describe('dangerouslySetInnerHTML', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// @gate !disableIEWorkarounds
|
||||
it('sets innerHTML on it', () => {
|
||||
const html = '<circle></circle>';
|
||||
const container = document.createElementNS(
|
||||
@@ -69,6 +70,7 @@ describe('dangerouslySetInnerHTML', () => {
|
||||
expect(circle.tagName).toBe('circle');
|
||||
});
|
||||
|
||||
// @gate !disableIEWorkarounds
|
||||
it('clears previous children', () => {
|
||||
const firstHtml = '<rect></rect>';
|
||||
const secondHtml = '<circle></circle>';
|
||||
|
||||
@@ -208,6 +208,7 @@ describe('when Trusted Types are available in global object', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// @gate !disableIEWorkarounds
|
||||
it('should log a warning', () => {
|
||||
class Component extends React.Component {
|
||||
render() {
|
||||
|
||||
@@ -169,6 +169,9 @@ export const enableTrustedTypesIntegration = false;
|
||||
// DOM properties
|
||||
export const disableInputAttributeSyncing = false;
|
||||
|
||||
// Remove IE and MsApp specific workarounds for innerHTML
|
||||
export const disableIEWorkarounds = __EXPERIMENTAL__;
|
||||
|
||||
// Filter certain DOM attributes (e.g. src, href) if their values are empty
|
||||
// strings. This prevents e.g. <img src=""> from making an unnecessary HTTP
|
||||
// request for certain browsers.
|
||||
|
||||
@@ -36,6 +36,7 @@ export const debugRenderPhaseSideEffectsForStrictMode = true;
|
||||
export const disableJavaScriptURLs = false;
|
||||
export const disableCommentsAsDOMContainers = true;
|
||||
export const disableInputAttributeSyncing = false;
|
||||
export const disableIEWorkarounds = true;
|
||||
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
|
||||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
|
||||
@@ -26,6 +26,7 @@ export const enableFetchInstrumentation = false;
|
||||
export const disableJavaScriptURLs = false;
|
||||
export const disableCommentsAsDOMContainers = true;
|
||||
export const disableInputAttributeSyncing = false;
|
||||
export const disableIEWorkarounds = true;
|
||||
export const enableSchedulerDebugging = false;
|
||||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
|
||||
@@ -26,6 +26,7 @@ export const enableFetchInstrumentation = true;
|
||||
export const disableJavaScriptURLs = false;
|
||||
export const disableCommentsAsDOMContainers = true;
|
||||
export const disableInputAttributeSyncing = false;
|
||||
export const disableIEWorkarounds = true;
|
||||
export const enableSchedulerDebugging = false;
|
||||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
|
||||
@@ -26,6 +26,7 @@ export const enableFetchInstrumentation = false;
|
||||
export const disableJavaScriptURLs = false;
|
||||
export const disableCommentsAsDOMContainers = true;
|
||||
export const disableInputAttributeSyncing = false;
|
||||
export const disableIEWorkarounds = true;
|
||||
export const enableSchedulerDebugging = false;
|
||||
export const enableScopeAPI = false;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
|
||||
@@ -27,6 +27,7 @@ export const enableSchedulerDebugging = false;
|
||||
export const disableJavaScriptURLs = false;
|
||||
export const disableCommentsAsDOMContainers = true;
|
||||
export const disableInputAttributeSyncing = false;
|
||||
export const disableIEWorkarounds = true;
|
||||
export const enableScopeAPI = true;
|
||||
export const enableCreateEventHandleAPI = false;
|
||||
export const enableSuspenseCallback = true;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// with the __VARIANT__ set to `true`, and once set to `false`.
|
||||
|
||||
export const disableInputAttributeSyncing = __VARIANT__;
|
||||
export const disableIEWorkarounds = __VARIANT__;
|
||||
export const enableFilterEmptyStringAttributesDOM = __VARIANT__;
|
||||
export const enableLegacyFBSupport = __VARIANT__;
|
||||
export const skipUnmountedBoundaries = __VARIANT__;
|
||||
|
||||
@@ -16,6 +16,7 @@ const dynamicFeatureFlags: DynamicFeatureFlags = require('ReactFeatureFlags');
|
||||
|
||||
export const {
|
||||
disableInputAttributeSyncing,
|
||||
disableIEWorkarounds,
|
||||
enableTrustedTypesIntegration,
|
||||
disableSchedulerTimeoutBasedOnReactExpirationTime,
|
||||
replayFailedUnitOfWorkWithInvokeGuardedCallback,
|
||||
|
||||
Reference in New Issue
Block a user