Fix #21972: Add onResize event to video elements (#21973)

* Fix #21972: Add `onResize` event to video elements

This is a simple fix for #21972 that adds support for the `onResize` media event.

I created a separate `videoEventTypes` array since I doubt anyone will want to add `onResize` to an audio event. It would simplify the code a bit to just add `resize` to the `mediaEventTypes` array, if that’s preferred.

Pre-commit checklist ([source](https://reactjs.org/docs/how-to-contribute.html#sending-a-pull-request))

 Fork the repository and create your branch from `main`.
 Run `yarn` in the repository root.
 If you’ve fixed a bug or added code that should be tested, add tests!
 Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
 Run `yarn test --prod` to test in the production environment.
 If you need a debugger, run `yarn debug-test --watch TestName`, open chrome://inspect, and press “Inspect”.
 Format your code with prettier (`yarn prettier`).
 Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
 Run the Flow typechecks (`yarn flow`).
 If you haven’t already, complete the CLA.

* Consolidate `videoEventTypes` array into `mediaEventTypes`
This commit is contained in:
Riley Shaw 2021-09-07 15:28:19 -07:00 committed by GitHub
parent 2f156eafb8
commit fbce2d5274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 0 deletions

View File

@ -21,6 +21,7 @@ export default class MediaEvents extends React.Component {
onPlaying: false,
onProgress: false,
onRateChange: false,
onResize: false,
onSeeked: false,
onSeeking: false,
onSuspend: false,

View File

@ -388,6 +388,7 @@ describe('ReactDOMEventListener', () => {
onPlaying() {},
onProgress() {},
onRateChange() {},
onResize() {},
onSeeked() {},
onSeeking() {},
onStalled() {},
@ -430,6 +431,7 @@ describe('ReactDOMEventListener', () => {
case 'playing':
case 'progress':
case 'ratechange':
case 'resize':
case 'seeked':
case 'seeking':
case 'stalled':

View File

@ -1095,6 +1095,22 @@ describe('ReactDOMEventListener', () => {
});
});
it('onResize', () => {
testEmulatedBubblingEvent({
type: 'video',
reactEvent: 'onResize',
reactEventType: 'resize',
nativeEvent: 'resize',
dispatch(node) {
const e = new Event('resize', {
bubbles: false,
cancelable: true,
});
node.dispatchEvent(e);
},
});
});
it('onSeeked', () => {
testEmulatedBubblingEvent({
type: 'video',

View File

@ -69,6 +69,7 @@ Array [
"progress",
"rateChange",
"reset",
"resize",
"scroll",
"seeked",
"seeking",

View File

@ -86,6 +86,7 @@ export type DOMEventName =
| 'progress'
| 'ratechange'
| 'reset'
| 'resize'
| 'scroll'
| 'seeked'
| 'seeking'

View File

@ -86,6 +86,7 @@ const simpleEventPluginEvents = [
'progress',
'rateChange',
'reset',
'resize',
'seeked',
'seeking',
'stalled',

View File

@ -192,6 +192,7 @@ export const mediaEventTypes: Array<DOMEventName> = [
'playing',
'progress',
'ratechange',
'resize',
'seeked',
'seeking',
'stalled',

View File

@ -321,6 +321,7 @@ export function getEventPriority(domEventName: DOMEventName): * {
case 'pointerup':
case 'ratechange':
case 'reset':
case 'resize':
case 'seeked':
case 'submit':
case 'touchcancel':

View File

@ -71,6 +71,7 @@ export type TopLevelType =
| 'progress'
| 'ratechange'
| 'reset'
| 'resize'
| 'scroll'
| 'seeked'
| 'seeking'

View File

@ -642,6 +642,7 @@ const simulatedEventTypes = [
'pointerUp',
'rateChange',
'reset',
'resize',
'seeked',
'submit',
'touchCancel',