Expose NodeList and MutationRecord in global scope (#47759)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47759

Changelog: [internal]

These interfaces should be available in the global scope, so this exposes them in their setup modules.

Reviewed By: javache

Differential Revision: D66232574

fbshipit-source-id: 191c579ffce3fb8b4b454b5c5725661ff160a46f
This commit is contained in:
Rubén Norte 2024-11-20 10:00:48 -08:00 committed by Facebook GitHub Bot
parent b2f624d054
commit 43554b5a0f
2 changed files with 19 additions and 6 deletions

View File

@ -8,8 +8,7 @@
* @format * @format
*/ */
import DOMRect from '../webapis/dom/geometry/DOMRect'; import {polyfillGlobal} from '../../../Libraries/Utilities/PolyfillFunctions';
import DOMRectReadOnly from '../webapis/dom/geometry/DOMRectReadOnly';
let initialized = false; let initialized = false;
@ -20,9 +19,18 @@ export default function setUpDOM() {
initialized = true; initialized = true;
// $FlowExpectedError[cannot-write] The global isn't writable anywhere but here, where we define it polyfillGlobal(
global.DOMRect = DOMRect; 'DOMRect',
() => require('../webapis/dom/geometry/DOMRect').default,
);
// $FlowExpectedError[cannot-write] The global isn't writable anywhere but here, where we define it polyfillGlobal(
global.DOMRectReadOnly = DOMRectReadOnly; 'DOMRectReadOnly',
() => require('../webapis/dom/geometry/DOMRectReadOnly').default,
);
polyfillGlobal(
'NodeList',
() => require('../webapis/dom/oldstylecollections/NodeList').default,
);
} }

View File

@ -23,4 +23,9 @@ export default function setUpMutationObserver() {
'MutationObserver', 'MutationObserver',
() => require('../webapis/mutationobserver/MutationObserver').default, () => require('../webapis/mutationobserver/MutationObserver').default,
); );
polyfillGlobal(
'MutationRecord',
() => require('../webapis/mutationobserver/MutationRecord').default,
);
} }