Skip to content

Commit a7cc853

Browse files
author
Sebastian Silbermann
committed
WIP
1 parent b513735 commit a7cc853

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

packages/react-dom-bindings/src/events/DOMEventNames.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type DOMEventName =
1818
// 'animationstart' |
1919
| 'beforeblur' // Not a real event. This is used by event experiments.
2020
| 'beforeinput'
21+
| 'beforematch'
2122
| 'blur'
2223
| 'canplay'
2324
| 'canplaythrough'

packages/react-dom-bindings/src/events/DOMEventProperties.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const topLevelEventsToReactNames: Map<DOMEventName, string | null> =
3434
const simpleEventPluginEvents = [
3535
'abort',
3636
'auxClick',
37+
'beforematch',
3738
'cancel',
3839
'canPlay',
3940
'canPlayThrough',

packages/react-dom-bindings/src/events/ReactDOMEventListener.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
} from 'react-reconciler/src/ReactEventPriorities';
5454
import ReactSharedInternals from 'shared/ReactSharedInternals';
5555
import {isRootDehydrated} from 'react-reconciler/src/ReactFiberShellHydration';
56+
import {enableNewDOMProps} from 'shared/ReactFeatureFlags';
5657

5758
const {ReactCurrentBatchConfig} = ReactSharedInternals;
5859

@@ -386,6 +387,11 @@ export function getEventPriority(domEventName: DOMEventName): EventPriority {
386387
return DefaultEventPriority;
387388
}
388389
}
390+
case 'beforematch':
391+
if (enableNewDOMProps) {
392+
return DiscreteEventPriority;
393+
}
394+
// fall through without enableNewDOMProps
389395
default:
390396
return DefaultEventPriority;
391397
}

packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ describe('ReactDOMEventListener', () => {
124124
});
125125
});
126126

127+
it('onBeforeMatch', async () => {
128+
await testNativeBubblingEvent({
129+
type: 'div',
130+
reactEvent: 'onBeforeMatch',
131+
reactEventType: 'beforematch',
132+
nativeEvent: 'beforematch',
133+
dispatch(node) {
134+
node.dispatchEvent(
135+
new KeyboardEvent('beforematch', {
136+
bubbles: true,
137+
cancelable: true,
138+
}),
139+
);
140+
},
141+
});
142+
});
143+
127144
it('onBlur', async () => {
128145
await testNativeBubblingEvent({
129146
type: 'input',

packages/react-dom/src/test-utils/ReactTestUtils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ function makeSimulator(eventType) {
627627

628628
// A one-time snapshot with no plans to update. We'll probably want to deprecate Simulate API.
629629
const simulatedEventTypes = [
630+
'beforematch',
630631
'blur',
631632
'cancel',
632633
'click',

0 commit comments

Comments
 (0)