EventTarget-based event dispatching (#56427)#56427
Open
rubennorte wants to merge 1 commit intofacebook:mainfrom
Open
EventTarget-based event dispatching (#56427)#56427rubennorte wants to merge 1 commit intofacebook:mainfrom
rubennorte wants to merge 1 commit intofacebook:mainfrom
Conversation
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100462547. |
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 13, 2026
Summary: Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
5cb8cf1 to
ed12ad8
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 13, 2026
Summary: Pull Request resolved: facebook#56427 Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
d7e3bdb to
dbc0a97
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Pull Request resolved: facebook#56427 Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
dbc0a97 to
ab4964f
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
ab4964f to
a929bca
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
a929bca to
4a77625
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Pull Request resolved: facebook#56427 Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
4a77625 to
3d0ab47
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Pull Request resolved: facebook#56427 Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
3d0ab47 to
cd5d24b
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 14, 2026
Summary: Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
cd5d24b to
f77bc3a
Compare
Summary: Pull Request resolved: facebook#56427 Changelog: [internal] ## Context React Native's event system currently dispatches events through a legacy plugin-based system. This change sets up an experiment to migrate to the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent), which enables imperative event handling on refs and aligns with web standards. The experiment is gated behind the `enableNativeEventTargetEventDispatching` feature flag (defaults to off). ## Changes - Add `EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEY` hook to EventTarget, allowing subclasses to provide prop-based listeners at dispatch time. In `invoke()`, the prop listener is prepended to the addEventListener listeners and processed through the same loop (no duplication). - ReactNativeElement overrides this hook to look up handlers from `canonical.currentProps` using a reverse mapping from event names to prop names (built lazily from the view config in `EventNameToPropName.js`). - Add `getCurrentProps` helper in `NodeInternals.js` to encapsulate private React API access. - Conditionally extend ReadOnlyNode from EventTarget when the flag is enabled, making addEventListener/removeEventListener/dispatchEvent available on element refs. - Export `setEventInitTimeStamp` and `dispatchTrustedEvent` from `ReactNativePrivateInterface` for use by the React renderer. - Set up global `RN$isNativeEventTargetEventDispatchingEnabled` function for the React renderer to check the flag value. Gated until the OSS renderer has been synced to OSS: - Add integration tests for event dispatching (prop handlers, addEventListener, ordering, capture/bubble phases, timestamps) and responder system (grant, release, transfer, negotiation, capture). - Add event dispatching benchmark. Differential Revision: D100462547
f77bc3a to
80747b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog: [internal]
Context
React Native's event system currently dispatches events through a legacy
plugin-based system. This change sets up an experiment to migrate to
the W3C EventTarget API (addEventListener/removeEventListener/dispatchEvent),
which enables imperative event handling on refs and aligns with web standards.
The experiment is gated behind the
enableNativeEventTargetEventDispatchingfeature flag (defaults to off).
Changes
EVENT_TARGET_GET_DECLARATIVE_LISTENER_KEYhook to EventTarget,allowing subclasses to provide prop-based listeners at dispatch time.
In
invoke(), the prop listener is prepended to the addEventListenerlisteners and processed through the same loop (no duplication).
canonical.currentPropsusing a reverse mapping from event namesto prop names (built lazily from the view config in
EventNameToPropName.js).getCurrentPropshelper inNodeInternals.jsto encapsulateprivate React API access.
enabled, making addEventListener/removeEventListener/dispatchEvent
available on element refs.
setEventInitTimeStampanddispatchTrustedEventfromReactNativePrivateInterfacefor use by the React renderer.RN$isNativeEventTargetEventDispatchingEnabledfunctionfor the React renderer to check the flag value.
Gated until the OSS renderer has been synced to OSS:
addEventListener, ordering, capture/bubble phases, timestamps) and
responder system (grant, release, transfer, negotiation, capture).
Differential Revision: D100462547