You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9dd979e
Browse filesBrowse the repository at this point in the historyBrowse files
Gate the public EventTarget API on ReactNativeElement and ReadOnlyText behind enableImperativeEvents (#57088)
Summary:
Pull Request resolved: #57088
## Context
We are migrating React Native event dispatching to the W3C `EventTarget` interface. That refactor is backwards compatible, but turning it on also incidentally exposes a brand new public API on component refs (`addEventListener`, `removeEventListener`, `dispatchEvent`). We want to decouple the event-dispatching refactor from shipping that new public API so we can roll out the refactor faster, without committing to the public surface before it is finalized.
## Changes
Adds a new JS-only feature flag, `enableImperativeEvents` (default off), that controls whether the final DOM node classes `ReactNativeElement` and `ReadOnlyText` expose the public `EventTarget` API.
- When `EventTarget`-based dispatching is enabled but `enableImperativeEvents` is off, `addEventListener`, `removeEventListener` and `dispatchEvent` are removed from those two final classes. Native and internal event dispatch do not rely on these public methods, so event delivery is unaffected.
- When `enableImperativeEvents` is on, the classes keep the full `EventTarget` API.
- Adds integration test coverage for both flag states, and pins the flag on in the existing `EventTarget` dispatching tests that exercise imperative listeners.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D107656477
fbshipit-source-id: 73835a059c8b43624fc1e4b9265c136386b29583
'When enabled, ReactNativeElement and ReadOnlyText expose the public EventTarget API (addEventListener, removeEventListener, dispatchEvent). When disabled, those methods are removed from those final classes.',
* When enabled, ReactNativeElement and ReadOnlyText expose the public EventTarget API (addEventListener, removeEventListener, dispatchEvent). When disabled, those methods are removed from those final classes.
* When enabled, the React Native renderer dispatches events through the W3C EventTarget API (addEventListener/dispatchEvent) instead of the legacy plugin-based system.
0 commit comments