@@ -29,8 +29,7 @@ import {
29
29
TOP_SUBMIT ,
30
30
TOP_TOGGLE ,
31
31
} from '../events/DOMTopLevelEventTypes' ;
32
- import { listenTo , trapBubbledEvent } from '../events/ReactBrowserEventEmitter' ;
33
- import { mediaEventTypes } from '../events/DOMTopLevelEventTypes' ;
32
+ import { listenTo , trapEvent } from '../events/ReactBrowserEventEmitter' ;
34
33
import * as CSSPropertyOperations from '../shared/CSSPropertyOperations' ;
35
34
import { Namespaces , getIntrinsicNamespace } from '../shared/DOMNamespaces' ;
36
35
import {
@@ -452,41 +451,29 @@ export function setInitialProperties(
452
451
switch ( tag ) {
453
452
case 'iframe ':
454
453
case 'object ':
455
- trapBubbledEvent ( TOP_LOAD , domElement ) ;
456
- props = rawProps ;
457
- break ;
458
- case 'video ':
459
- case 'audio ':
460
- // Create listener for each media event
461
- for ( let i = 0 ; i < mediaEventTypes . length ; i ++ ) {
462
- trapBubbledEvent ( mediaEventTypes [ i ] , domElement ) ;
463
- }
464
- props = rawProps ;
465
- break ;
466
- case 'source' :
467
- trapBubbledEvent ( TOP_ERROR , domElement ) ;
454
+ trapEvent ( TOP_LOAD , domElement ) ;
468
455
props = rawProps ;
469
456
break ;
470
457
case 'img ':
471
458
case 'image ':
472
459
case 'link ':
473
- trapBubbledEvent ( TOP_ERROR , domElement ) ;
474
- trapBubbledEvent ( TOP_LOAD , domElement ) ;
460
+ trapEvent ( TOP_ERROR , domElement ) ;
461
+ trapEvent ( TOP_LOAD , domElement ) ;
475
462
props = rawProps ;
476
463
break ;
477
464
case 'form ':
478
- trapBubbledEvent ( TOP_RESET , domElement ) ;
479
- trapBubbledEvent ( TOP_SUBMIT , domElement ) ;
465
+ trapEvent ( TOP_RESET , domElement ) ;
466
+ trapEvent ( TOP_SUBMIT , domElement ) ;
480
467
props = rawProps ;
481
468
break ;
482
469
case 'details ':
483
- trapBubbledEvent ( TOP_TOGGLE , domElement ) ;
470
+ trapEvent ( TOP_TOGGLE , domElement ) ;
484
471
props = rawProps ;
485
472
break ;
486
473
case 'input ':
487
474
ReactDOMFiberInput . initWrapperState ( domElement , rawProps ) ;
488
475
props = ReactDOMFiberInput . getHostProps ( domElement , rawProps ) ;
489
- trapBubbledEvent ( TOP_INVALID , domElement ) ;
476
+ trapEvent ( TOP_INVALID , domElement ) ;
490
477
// For controlled components we always need to ensure we're listening
491
478
// to onChange. Even if there is no listener.
492
479
ensureListeningTo ( rootContainerElement , 'onChange' ) ;
@@ -498,15 +485,15 @@ export function setInitialProperties(
498
485
case 'select ':
499
486
ReactDOMFiberSelect . initWrapperState ( domElement , rawProps ) ;
500
487
props = ReactDOMFiberSelect . getHostProps ( domElement , rawProps ) ;
501
- trapBubbledEvent ( TOP_INVALID , domElement ) ;
488
+ trapEvent ( TOP_INVALID , domElement ) ;
502
489
// For controlled components we always need to ensure we're listening
503
490
// to onChange. Even if there is no listener.
504
491
ensureListeningTo ( rootContainerElement , 'onChange' ) ;
505
492
break ;
506
493
case 'textarea ':
507
494
ReactDOMFiberTextarea . initWrapperState ( domElement , rawProps ) ;
508
495
props = ReactDOMFiberTextarea . getHostProps ( domElement , rawProps ) ;
509
- trapBubbledEvent ( TOP_INVALID , domElement ) ;
496
+ trapEvent ( TOP_INVALID , domElement ) ;
510
497
// For controlled components we always need to ensure we're listening
511
498
// to onChange. Even if there is no listener.
512
499
ensureListeningTo ( rootContainerElement , 'onChange' ) ;
@@ -843,34 +830,27 @@ export function diffHydratedProperties(
843
830
switch ( tag ) {
844
831
case 'iframe ':
845
832
case 'object ':
846
- trapBubbledEvent ( TOP_LOAD , domElement ) ;
847
- break ;
848
- case 'video ':
849
- case 'audio ':
850
- // Create listener for each media event
851
- for ( let i = 0 ; i < mediaEventTypes . length ; i ++ ) {
852
- trapBubbledEvent ( mediaEventTypes [ i ] , domElement ) ;
853
- }
833
+ trapEvent ( TOP_LOAD , domElement ) ;
854
834
break ;
855
835
case 'source ':
856
- trapBubbledEvent ( TOP_ERROR , domElement ) ;
836
+ trapEvent ( TOP_ERROR , domElement ) ;
857
837
break ;
858
838
case 'img ':
859
839
case 'image ':
860
840
case 'link ':
861
- trapBubbledEvent ( TOP_ERROR , domElement ) ;
862
- trapBubbledEvent ( TOP_LOAD , domElement ) ;
841
+ trapEvent ( TOP_ERROR , domElement ) ;
842
+ trapEvent ( TOP_LOAD , domElement ) ;
863
843
break ;
864
844
case 'form ':
865
- trapBubbledEvent ( TOP_RESET , domElement ) ;
866
- trapBubbledEvent ( TOP_SUBMIT , domElement ) ;
845
+ trapEvent ( TOP_RESET , domElement ) ;
846
+ trapEvent ( TOP_SUBMIT , domElement ) ;
867
847
break ;
868
848
case 'details ':
869
- trapBubbledEvent ( TOP_TOGGLE , domElement ) ;
849
+ trapEvent ( TOP_TOGGLE , domElement ) ;
870
850
break ;
871
851
case 'input ':
872
852
ReactDOMFiberInput . initWrapperState ( domElement , rawProps ) ;
873
- trapBubbledEvent ( TOP_INVALID , domElement ) ;
853
+ trapEvent ( TOP_INVALID , domElement ) ;
874
854
// For controlled components we always need to ensure we're listening
875
855
// to onChange. Even if there is no listener.
876
856
ensureListeningTo ( rootContainerElement , 'onChange' ) ;
@@ -880,14 +860,14 @@ export function diffHydratedProperties(
880
860
break ;
881
861
case 'select ':
882
862
ReactDOMFiberSelect . initWrapperState ( domElement , rawProps ) ;
883
- trapBubbledEvent ( TOP_INVALID , domElement ) ;
863
+ trapEvent ( TOP_INVALID , domElement ) ;
884
864
// For controlled components we always need to ensure we're listening
885
865
// to onChange. Even if there is no listener.
886
866
ensureListeningTo ( rootContainerElement , 'onChange' ) ;
887
867
break ;
888
868
case 'textarea ':
889
869
ReactDOMFiberTextarea . initWrapperState ( domElement , rawProps ) ;
890
- trapBubbledEvent ( TOP_INVALID , domElement ) ;
870
+ trapEvent ( TOP_INVALID , domElement ) ;
891
871
// For controlled components we always need to ensure we're listening
892
872
// to onChange. Even if there is no listener.
893
873
ensureListeningTo ( rootContainerElement , 'onChange' ) ;
0 commit comments