From 3be136070f52d83b54739047b2071f16bbeb0183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Sat, 11 Apr 2026 08:39:15 -0700 Subject: [PATCH 1/2] Expose Event, EventTarget and CustomEvent as globals Summary: Registers Event, EventTarget and CustomEvent as global polyfills in `setUpDOM.js`. These are standard Web APIs that DOM nodes need access to. Removes the Event/EventTarget polyfills from the Fantom test setup since they are now provided globally by setUpDOM.js. Changelog: [internal] Marking as internal for now, until we ship to stable, even though this isn't gated. We shouldn't communicate this yet. Differential Revision: D100462548 --- .../src/private/setup/setUpDOM.js | 12 ++++++++++ private/react-native-fantom/src/index.js | 22 ------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/packages/react-native/src/private/setup/setUpDOM.js b/packages/react-native/src/private/setup/setUpDOM.js index a506401440c2..b24ab3d3f4f7 100644 --- a/packages/react-native/src/private/setup/setUpDOM.js +++ b/packages/react-native/src/private/setup/setUpDOM.js @@ -73,4 +73,16 @@ export default function setUpDOM() { 'HTMLElement', () => require('../webapis/dom/nodes/ReactNativeElement').default, ); + + polyfillGlobal('Event', () => require('../webapis/dom/events/Event').default); + + polyfillGlobal( + 'EventTarget', + () => require('../webapis/dom/events/EventTarget').default, + ); + + polyfillGlobal( + 'CustomEvent', + () => require('../webapis/dom/events/CustomEvent').default, + ); } diff --git a/private/react-native-fantom/src/index.js b/private/react-native-fantom/src/index.js index 72304f15d012..19dff0d6cb64 100644 --- a/private/react-native-fantom/src/index.js +++ b/private/react-native-fantom/src/index.js @@ -712,26 +712,4 @@ function getNode(nodeOrRef: NodeOrRef): ReadOnlyNode { } } -/** - * Quick and dirty polyfills required by tinybench. - */ - -if (typeof global.Event === 'undefined') { - global.Event = - require('react-native/src/private/webapis/dom/events/Event').default; -} else { - console.warn( - 'The global Event class is already defined. If this API is already defined by React Native, you might want to remove this logic.', - ); -} - -if (typeof global.EventTarget === 'undefined') { - global.EventTarget = - require('react-native/src/private/webapis/dom/events/EventTarget').default; -} else { - console.warn( - 'The global Event class is already defined. If this API is already defined by React Native, you might want to remove this logic.', - ); -} - global.__FANTOM_PACKAGE_LOADED__ = true; From 4677ddf930465a59b8a44437e8763ff85c7d0c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Sat, 11 Apr 2026 08:39:15 -0700 Subject: [PATCH 2/2] Expose dispatchTrustedEvent and setEventInitTimeStamp in ReactNativePrivateInterface Summary: Changelog: [internal] The React Native renderer needs access to these internals to dispatch events under the new EventTarget-based event dispatching pipeline. Differential Revision: D100462549 --- .../ReactPrivate/ReactNativePrivateInterface.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js index 6365f1bee485..385f5c921941 100644 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js @@ -9,6 +9,8 @@ */ import typeof CustomEvent from '../../src/private/webapis/dom/events/CustomEvent'; +import typeof {setEventInitTimeStamp} from '../../src/private/webapis/dom/events/internals/EventInternals'; +import typeof {dispatchTrustedEvent} from '../../src/private/webapis/dom/events/internals/EventTargetInternals'; import typeof BatchedBridge from '../BatchedBridge/BatchedBridge'; import typeof legacySendAccessibilityEvent from '../Components/AccessibilityInfo/legacySendAccessibilityEvent'; import typeof TextInputState from '../Components/TextInput/TextInputState'; @@ -133,4 +135,12 @@ module.exports = { return require('../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance') .getInternalInstanceHandleFromPublicInstance; }, + get dispatchTrustedEvent(): dispatchTrustedEvent { + return require('../../src/private/webapis/dom/events/internals/EventTargetInternals') + .dispatchTrustedEvent; + }, + get setEventInitTimeStamp(): setEventInitTimeStamp { + return require('../../src/private/webapis/dom/events/internals/EventInternals') + .setEventInitTimeStamp; + }, };