Skip to content

Commit

Permalink
Avoid extra indirection
Browse files Browse the repository at this point in the history
This is still doing feature tests in the module scope but no calls
  • Loading branch information
sebmarkbage committed Mar 15, 2023
1 parent 2f4cb62 commit 4c40846
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 38 deletions.

This file was deleted.

37 changes: 24 additions & 13 deletions packages/react-dom-bindings/src/client/setInnerHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,15 @@
* @flow
*/

/* globals MSApp */

import {SVG_NAMESPACE} from './DOMNamespaces';
import createMicrosoftUnsafeLocalFunction from './createMicrosoftUnsafeLocalFunction';
import {enableTrustedTypesIntegration} from 'shared/ReactFeatureFlags';

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

/**
* Set the innerHTML property of a node
*
* @param {DOMElement} node
* @param {string} html
* @internal
*/
const setInnerHTML: (
node: Element,
html: {valueOf(): {toString(): string, ...}, ...},
) => void = createMicrosoftUnsafeLocalFunction(function (
function setInnerHTMLImpl(
node: Element,
html: {valueOf(): {toString(): string, ...}, ...},
): void {
Expand Down Expand Up @@ -66,6 +57,26 @@ const setInnerHTML: (
}
}
node.innerHTML = (html: any);
});
}

let setInnerHTML: (
node: Element,
html: {valueOf(): {toString(): string, ...}, ...},
) => void = setInnerHTMLImpl;
// $FlowFixMe[cannot-resolve-name]
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
/**
* Create a function which has 'unsafe' privileges (required by windows8 apps)
*/
setInnerHTML = function (
node: Element,
html: {valueOf(): {toString(): string, ...}, ...},
): void {
// $FlowFixMe[cannot-resolve-name]
return MSApp.execUnsafeLocalFunction(function () {
return setInnerHTMLImpl(node, html);
});
};
}

export default setInnerHTML;

0 comments on commit 4c40846

Please sign in to comment.