|
7 | 7 | * @flow |
8 | 8 | */ |
9 | 9 |
|
| 10 | +/* globals MSApp */ |
| 11 | + |
10 | 12 | import {SVG_NAMESPACE} from './DOMNamespaces'; |
11 | | -import createMicrosoftUnsafeLocalFunction from './createMicrosoftUnsafeLocalFunction'; |
12 | 13 | import {enableTrustedTypesIntegration} from 'shared/ReactFeatureFlags'; |
13 | 14 |
|
14 | 15 | // SVG temp container for IE lacking innerHTML |
15 | 16 | let reusableSVGContainer: HTMLElement; |
16 | 17 |
|
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( |
28 | 19 | node: Element, |
29 | 20 | html: {valueOf(): {toString(): string, ...}, ...}, |
30 | 21 | ): void { |
@@ -66,6 +57,26 @@ const setInnerHTML: ( |
66 | 57 | } |
67 | 58 | } |
68 | 59 | 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 | +} |
70 | 81 |
|
71 | 82 | export default setInnerHTML; |
0 commit comments