Skip to content

Commit 1e92969

Browse files
committed
Avoid extra indirection
This is still doing feature tests in the module scope but no calls
1 parent b249b5e commit 1e92969

2 files changed

Lines changed: 24 additions & 38 deletions

File tree

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

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,15 @@
77
* @flow
88
*/
99

10+
/* globals MSApp */
11+
1012
import {SVG_NAMESPACE} from './DOMNamespaces';
11-
import createMicrosoftUnsafeLocalFunction from './createMicrosoftUnsafeLocalFunction';
1213
import {enableTrustedTypesIntegration} from 'shared/ReactFeatureFlags';
1314

1415
// SVG temp container for IE lacking innerHTML
1516
let reusableSVGContainer: HTMLElement;
1617

17-
/**
18-
* Set the innerHTML property of a node
19-
*
20-
* @param {DOMElement} node
21-
* @param {string} html
22-
* @internal
23-
*/
24-
const setInnerHTML: (
25-
node: Element,
26-
html: {valueOf(): {toString(): string, ...}, ...},
27-
) => void = createMicrosoftUnsafeLocalFunction(function (
18+
function setInnerHTMLImpl(
2819
node: Element,
2920
html: {valueOf(): {toString(): string, ...}, ...},
3021
): void {
@@ -66,6 +57,26 @@ const setInnerHTML: (
6657
}
6758
}
6859
node.innerHTML = (html: any);
69-
});
60+
}
61+
62+
let setInnerHTML: (
63+
node: Element,
64+
html: {valueOf(): {toString(): string, ...}, ...},
65+
) => void = setInnerHTMLImpl;
66+
// $FlowFixMe[cannot-resolve-name]
67+
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
68+
/**
69+
* Create a function which has 'unsafe' privileges (required by windows8 apps)
70+
*/
71+
setInnerHTML = function (
72+
node: Element,
73+
html: {valueOf(): {toString(): string, ...}, ...},
74+
): void {
75+
// $FlowFixMe[cannot-resolve-name]
76+
return MSApp.execUnsafeLocalFunction(function () {
77+
return setInnerHTMLImpl(node, html);
78+
});
79+
};
80+
}
7081

7182
export default setInnerHTML;

0 commit comments

Comments
 (0)