Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 28, 2024
1 parent b513735 commit a7cc853
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-dom-bindings/src/events/DOMEventNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type DOMEventName =
// 'animationstart' |
| 'beforeblur' // Not a real event. This is used by event experiments.
| 'beforeinput'
| 'beforematch'
| 'blur'
| 'canplay'
| 'canplaythrough'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const topLevelEventsToReactNames: Map<DOMEventName, string | null> =
const simpleEventPluginEvents = [
'abort',
'auxClick',
'beforematch',
'cancel',
'canPlay',
'canPlayThrough',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
} from 'react-reconciler/src/ReactEventPriorities';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {isRootDehydrated} from 'react-reconciler/src/ReactFiberShellHydration';
import {enableNewDOMProps} from 'shared/ReactFeatureFlags';

const {ReactCurrentBatchConfig} = ReactSharedInternals;

Expand Down Expand Up @@ -386,6 +387,11 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
return DefaultEventPriority;
}
}
case 'beforematch':
if (enableNewDOMProps) {
return DiscreteEventPriority;
}
// fall through without enableNewDOMProps
default:
return DefaultEventPriority;
}
Expand Down
17 changes: 17 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ describe('ReactDOMEventListener', () => {
});
});

it('onBeforeMatch', async () => {
await testNativeBubblingEvent({
type: 'div',
reactEvent: 'onBeforeMatch',
reactEventType: 'beforematch',
nativeEvent: 'beforematch',
dispatch(node) {
node.dispatchEvent(
new KeyboardEvent('beforematch', {
bubbles: true,
cancelable: true,
}),
);
},
});
});

it('onBlur', async () => {
await testNativeBubblingEvent({
type: 'input',
Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/test-utils/ReactTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ function makeSimulator(eventType) {

// A one-time snapshot with no plans to update. We'll probably want to deprecate Simulate API.
const simulatedEventTypes = [
'beforematch',
'blur',
'cancel',
'click',
Expand Down

0 comments on commit a7cc853

Please sign in to comment.