EventTarget-based event dispatching (#56427)#56427
Closed
rubennorte wants to merge 1 commit intofacebook:mainfrom
Closed
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
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
f77bc3a to
80747b1
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
80747b1 to
b4e39bb
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
b4e39bb to
3698a10
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
3698a10 to
fcd7371
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
fcd7371 to
1774d13
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
1774d13 to
4f6ebd3
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
4f6ebd3 to
352f503
Compare
352f503 to
bec68ae
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 15, 2026
Summary: Changelog: [internal] ## Context The current React Native Fabric renderer uses a legacy plugin-based event system (ResponderEventPlugin, ReactNativeBridgeEventPlugin, pooled SyntheticEvent objects) that duplicates dispatch logic already provided by the W3C EventTarget API. This adds complexity, prevents alignment with the Web platform, and blocks EventTarget-based features. ## Changes Behind the `enableNativeEventTargetEventDispatching` flag, native events are dispatched through `dispatchTrustedEvent` on the public instance tree instead of the legacy plugin system. Event handler props are extracted from `canonical.currentProps` at dispatch time via a declarative listener hook on EventTarget — no `addEventListener` registration at commit time. The responder system is fully self-contained: it walks the public instance tree directly for negotiation, calls handlers from props, and inspects return values inline (e.g. `onResponderGrant` returning `true` blocks native). It has no EventTarget coupling and no commit-time cost. Reviewed By: jackpope Differential Revision: D100462547
bec68ae to
fc1e11b
Compare
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 15, 2026
Summary: Changelog: [internal] ## Context The current React Native Fabric renderer uses a legacy plugin-based event system (ResponderEventPlugin, ReactNativeBridgeEventPlugin, pooled SyntheticEvent objects) that duplicates dispatch logic already provided by the W3C EventTarget API. This adds complexity, prevents alignment with the Web platform, and blocks EventTarget-based features. ## Changes Behind the `enableNativeEventTargetEventDispatching` flag, native events are dispatched through `dispatchTrustedEvent` on the public instance tree instead of the legacy plugin system. Event handler props are extracted from `canonical.currentProps` at dispatch time via a declarative listener hook on EventTarget — no `addEventListener` registration at commit time. The responder system is fully self-contained: it walks the public instance tree directly for negotiation, calls handlers from props, and inspects return values inline (e.g. `onResponderGrant` returning `true` blocks native). It has no EventTarget coupling and no commit-time cost. Reviewed By: jackpope Differential Revision: D100462547
fc1e11b to
0cb4794
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 15, 2026
Summary: Pull Request resolved: facebook#56427 Changelog: [internal] ## Context The current React Native Fabric renderer uses a legacy plugin-based event system (ResponderEventPlugin, ReactNativeBridgeEventPlugin, pooled SyntheticEvent objects) that duplicates dispatch logic already provided by the W3C EventTarget API. This adds complexity, prevents alignment with the Web platform, and blocks EventTarget-based features. ## Changes Behind the `enableNativeEventTargetEventDispatching` flag, native events are dispatched through `dispatchTrustedEvent` on the public instance tree instead of the legacy plugin system. Event handler props are extracted from `canonical.currentProps` at dispatch time via a declarative listener hook on EventTarget — no `addEventListener` registration at commit time. The responder system is fully self-contained: it walks the public instance tree directly for negotiation, calls handlers from props, and inspects return values inline (e.g. `onResponderGrant` returning `true` blocks native). It has no EventTarget coupling and no commit-time cost. Reviewed By: jackpope Differential Revision: D100462547
0cb4794 to
e700843
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Apr 15, 2026
Summary: Changelog: [internal] ## Context The current React Native Fabric renderer uses a legacy plugin-based event system (ResponderEventPlugin, ReactNativeBridgeEventPlugin, pooled SyntheticEvent objects) that duplicates dispatch logic already provided by the W3C EventTarget API. This adds complexity, prevents alignment with the Web platform, and blocks EventTarget-based features. ## Changes Behind the `enableNativeEventTargetEventDispatching` flag, native events are dispatched through `dispatchTrustedEvent` on the public instance tree instead of the legacy plugin system. Event handler props are extracted from `canonical.currentProps` at dispatch time via a declarative listener hook on EventTarget — no `addEventListener` registration at commit time. The responder system is fully self-contained: it walks the public instance tree directly for negotiation, calls handlers from props, and inspects return values inline (e.g. `onResponderGrant` returning `true` blocks native). It has no EventTarget coupling and no commit-time cost. Reviewed By: jackpope Differential Revision: D100462547
e700843 to
a7ea592
Compare
Summary: Changelog: [internal] ## Context The current React Native Fabric renderer uses a legacy plugin-based event system (ResponderEventPlugin, ReactNativeBridgeEventPlugin, pooled SyntheticEvent objects) that duplicates dispatch logic already provided by the W3C EventTarget API. This adds complexity, prevents alignment with the Web platform, and blocks EventTarget-based features. ## Changes Behind the `enableNativeEventTargetEventDispatching` flag, native events are dispatched through `dispatchTrustedEvent` on the public instance tree instead of the legacy plugin system. Event handler props are extracted from `canonical.currentProps` at dispatch time via a declarative listener hook on EventTarget — no `addEventListener` registration at commit time. The responder system is fully self-contained: it walks the public instance tree directly for negotiation, calls handlers from props, and inspects return values inline (e.g. `onResponderGrant` returning `true` blocks native). It has no EventTarget coupling and no commit-time cost. Reviewed By: javache, jackpope Differential Revision: D100462547
a7ea592 to
136e393
Compare
|
This pull request has been merged in d1a8a1f. |
Collaborator
|
This pull request was successfully merged by @rubennorte in d1a8a1f When will my fix make it into a release? | How to file a pick request? |
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
The current React Native Fabric renderer uses a legacy plugin-based
event system (ResponderEventPlugin, ReactNativeBridgeEventPlugin,
pooled SyntheticEvent objects) that duplicates dispatch logic already
provided by the W3C EventTarget API. This adds complexity, prevents
alignment with the Web platform, and blocks EventTarget-based features.
Changes
Behind the
enableNativeEventTargetEventDispatchingflag, native eventsare dispatched through
dispatchTrustedEventon the public instancetree instead of the legacy plugin system. Event handler props are
extracted from
canonical.currentPropsat dispatch time via adeclarative listener hook on EventTarget — no
addEventListenerregistration at commit time.
The responder system is fully self-contained: it walks the public
instance tree directly for negotiation, calls handlers from props, and
inspects return values inline (e.g.
onResponderGrantreturningtrueblocks native). It has no EventTarget coupling and no commit-time cost.
Reviewed By: javache, jackpope
Differential Revision: D100462547