Skip to content

Commit 441804f

Browse files
committed
Remove disableIEWorkarounds
1 parent 30a81df commit 441804f

11 files changed

+17
-112
lines changed

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

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import {validateProperties as validateUnknownProperties} from '../shared/ReactDO
6666
import sanitizeURL from '../shared/sanitizeURL';
6767

6868
import {
69-
disableIEWorkarounds,
7069
enableTrustedTypesIntegration,
7170
enableFilterEmptyStringAttributesDOM,
7271
} from 'shared/ReactFeatureFlags';
@@ -83,19 +82,8 @@ let didWarnFormActionTarget = false;
8382
let didWarnFormActionMethod = false;
8483
let didWarnForNewBooleanPropsWithEmptyValue: {[string]: boolean};
8584
let didWarnPopoverTargetObject = false;
86-
let canDiffStyleForHydrationWarning;
8785
if (__DEV__) {
8886
didWarnForNewBooleanPropsWithEmptyValue = {};
89-
// IE 11 parses & normalizes the style attribute as opposed to other
90-
// browsers. It adds spaces and sorts the properties in some
91-
// non-alphabetical order. Handling that would require sorting CSS
92-
// properties in the client & server versions or applying
93-
// `expectedStyle` to a temporary DOM node to read its `style` attribute
94-
// normalized. Since it only affects IE, we're skipping style warnings
95-
// in that browser completely in favor of doing all that work.
96-
// See https://github.com/facebook/react/issues/11807
97-
canDiffStyleForHydrationWarning =
98-
disableIEWorkarounds || (canUseDOM && !document.documentMode);
9987
}
10088

10189
function validatePropertiesInDevelopment(type: string, props: any) {
@@ -579,11 +567,7 @@ function setProp(
579567
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.',
580568
);
581569
}
582-
if (disableIEWorkarounds) {
583-
domElement.innerHTML = nextHtml;
584-
} else {
585-
setInnerHTML(domElement, nextHtml);
586-
}
570+
domElement.innerHTML = nextHtml;
587571
}
588572
}
589573
break;
@@ -939,11 +923,7 @@ function setPropOnCustomElement(
939923
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.',
940924
);
941925
}
942-
if (disableIEWorkarounds) {
943-
domElement.innerHTML = nextHtml;
944-
} else {
945-
setInnerHTML(domElement, nextHtml);
946-
}
926+
domElement.innerHTML = nextHtml;
947927
}
948928
}
949929
break;
@@ -1931,27 +1911,23 @@ function diffHydratedStyles(
19311911
}
19321912
return;
19331913
}
1934-
if (canDiffStyleForHydrationWarning) {
1935-
// First we compare the string form and see if it's equivalent.
1936-
// This lets us bail out on anything that used to pass in this form.
1937-
// It also lets us compare anything that's not parsed by this browser.
1938-
const clientValue = createDangerousStringForStyles(value);
1939-
const serverValue = domElement.getAttribute('style');
1914+
// First we compare the string form and see if it's equivalent.
1915+
// This lets us bail out on anything that used to pass in this form.
1916+
// It also lets us compare anything that's not parsed by this browser.
1917+
const clientValue = createDangerousStringForStyles(value);
1918+
const serverValue = domElement.getAttribute('style');
19401919

1941-
if (serverValue === clientValue) {
1942-
return;
1943-
}
1944-
const normalizedClientValue =
1945-
normalizeMarkupForTextOrAttribute(clientValue);
1946-
const normalizedServerValue =
1947-
normalizeMarkupForTextOrAttribute(serverValue);
1948-
if (normalizedServerValue === normalizedClientValue) {
1949-
return;
1950-
}
1951-
1952-
// Otherwise, we create the object from the DOM for the diff view.
1953-
serverDifferences.style = getStylesObjectFromElement(domElement);
1920+
if (serverValue === clientValue) {
1921+
return;
1922+
}
1923+
const normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
1924+
const normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
1925+
if (normalizedServerValue === normalizedClientValue) {
1926+
return;
19541927
}
1928+
1929+
// Otherwise, we create the object from the DOM for the diff view.
1930+
serverDifferences.style = getStylesObjectFromElement(domElement);
19551931
}
19561932

19571933
function hydrateAttribute(

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,42 +58,5 @@ describe('dangerouslySetInnerHTML', () => {
5858
innerHTMLDescriptor,
5959
);
6060
});
61-
62-
// @gate !disableIEWorkarounds
63-
it('sets innerHTML on it', async () => {
64-
const html = '<circle></circle>';
65-
const container = document.createElementNS(
66-
'http://www.w3.org/2000/svg',
67-
'svg',
68-
);
69-
const root = ReactDOMClient.createRoot(container);
70-
await act(() => {
71-
root.render(<g dangerouslySetInnerHTML={{__html: html}} />);
72-
});
73-
const circle = container.firstChild.firstChild;
74-
expect(circle.tagName).toBe('circle');
75-
});
76-
77-
// @gate !disableIEWorkarounds
78-
it('clears previous children', async () => {
79-
const firstHtml = '<rect></rect>';
80-
const secondHtml = '<circle></circle>';
81-
82-
const container = document.createElementNS(
83-
'http://www.w3.org/2000/svg',
84-
'svg',
85-
);
86-
const root = ReactDOMClient.createRoot(container);
87-
await act(() => {
88-
root.render(<g dangerouslySetInnerHTML={{__html: firstHtml}} />);
89-
});
90-
const rect = container.firstChild.firstChild;
91-
expect(rect.tagName).toBe('rect');
92-
await act(() => {
93-
root.render(<g dangerouslySetInnerHTML={{__html: secondHtml}} />);
94-
});
95-
const circle = container.firstChild.firstChild;
96-
expect(circle.tagName).toBe('circle');
97-
});
9861
});
9962
});

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -231,29 +231,6 @@ describe('when Trusted Types are available in global object', () => {
231231
innerHTMLDescriptor,
232232
);
233233
});
234-
235-
// @gate !disableIEWorkarounds
236-
it('should log a warning', async () => {
237-
class Component extends React.Component {
238-
render() {
239-
return <svg dangerouslySetInnerHTML={{__html: 'unsafe html'}} />;
240-
}
241-
}
242-
const root = ReactDOMClient.createRoot(container);
243-
await expect(async () => {
244-
await act(() => {
245-
root.render(<Component />);
246-
});
247-
}).toErrorDev(
248-
"Using 'dangerouslySetInnerHTML' in an svg element with " +
249-
'Trusted Types enabled in an Internet Explorer will cause ' +
250-
'the trusted value to be converted to string. Assigning string ' +
251-
"to 'innerHTML' will throw an error if Trusted Types are enforced. " +
252-
"You can try to wrap your svg element inside a div and use 'dangerouslySetInnerHTML' " +
253-
'on the enclosing div instead.',
254-
);
255-
expect(container.innerHTML).toBe('<svg>unsafe html</svg>');
256-
});
257234
});
258235

259236
it('should warn once when rendering script tag in jsx on client', async () => {

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,6 @@ export const disableLegacyContextForFunctionComponents = true;
203203
// TODO: clean up legacy <StrictMode /> once tests pass WWW.
204204
export const useModernStrictMode = true;
205205

206-
// Not ready to break experimental yet.
207-
// Remove IE and MsApp specific workarounds for innerHTML
208-
export const disableIEWorkarounds = true;
209-
210206
// Filter certain DOM attributes (e.g. src, href) if their values are empty
211207
// strings. This prevents e.g. <img src=""> from making an unnecessary HTTP
212208
// request for certain browsers.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const debugRenderPhaseSideEffectsForStrictMode = __DEV__;
3636
export const disableClientCache = true;
3737
export const disableCommentsAsDOMContainers = true;
3838
export const disableDefaultPropsExceptForClasses = true;
39-
export const disableIEWorkarounds = true;
4039
export const disableInputAttributeSyncing = false;
4140
export const disableLegacyContext = false;
4241
export const disableLegacyContextForFunctionComponents = false;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const alwaysThrottleRetries = false;
2323
export const disableClientCache = true;
2424
export const disableCommentsAsDOMContainers = true;
2525
export const disableDefaultPropsExceptForClasses = true;
26-
export const disableIEWorkarounds = true;
2726
export const disableInputAttributeSyncing = false;
2827
export const disableLegacyContext = true;
2928
export const disableLegacyContextForFunctionComponents = true;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const enablePostpone = false;
2929
export const enableHalt = false;
3030
export const disableCommentsAsDOMContainers = true;
3131
export const disableInputAttributeSyncing = false;
32-
export const disableIEWorkarounds = true;
3332
export const enableScopeAPI = false;
3433
export const enableCreateEventHandleAPI = false;
3534
export const enableSuspenseCallback = false;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export const debugRenderPhaseSideEffectsForStrictMode = false;
1515
export const disableClientCache = true;
1616
export const disableCommentsAsDOMContainers = true;
1717
export const disableDefaultPropsExceptForClasses = true;
18-
export const disableIEWorkarounds = true;
1918
export const disableInputAttributeSyncing = false;
2019
export const disableLegacyContext = false;
2120
export const disableLegacyContextForFunctionComponents = false;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export const enablePostpone = false;
2929
export const enableHalt = false;
3030
export const disableCommentsAsDOMContainers = true;
3131
export const disableInputAttributeSyncing = false;
32-
export const disableIEWorkarounds = true;
3332
export const enableScopeAPI = true;
3433
export const enableCreateEventHandleAPI = false;
3534
export const enableSuspenseCallback = true;

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export const enableFabricCompleteRootInCommitPhase = false;
5353
export const enableSuspenseAvoidThisFallback = true;
5454
export const enableSuspenseAvoidThisFallbackFizz = false;
5555

56-
export const disableIEWorkarounds = true;
5756
export const enableCPUSuspense = true;
5857
export const enableUseMemoCacheHook = true;
5958
export const enableUseEffectEventHook = true;

0 commit comments

Comments
 (0)