File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ class Event {
125125 get bubbles ( ) { return this . #bubbles; }
126126 get composed ( ) { return this . #composed; }
127127 get eventPhase ( ) {
128- return this [ kTarget ] ? 2 : 0 ; // Equivalent to AT_TARGET or NONE
128+ return this [ kTarget ] ? Event . AT_TARGET : Event . NONE ;
129129 }
130130 get cancelBubble ( ) { return this . #propagationStopped; }
131131 set cancelBubble ( value ) {
@@ -136,6 +136,11 @@ class Event {
136136 stopPropagation ( ) {
137137 this . #propagationStopped = true ;
138138 }
139+
140+ static NONE = 0 ;
141+ static CAPTURING_PHASE = 1 ;
142+ static AT_TARGET = 2 ;
143+ static BUBBLING_PHASE = 3 ;
139144}
140145
141146Object . defineProperty ( Event . prototype , SymbolToStringTag , {
Original file line number Diff line number Diff line change @@ -432,7 +432,6 @@ ok(EventTarget);
432432 target . removeEventListener ( 'foo' , a , { capture : false } ) ;
433433 target . dispatchEvent ( new Event ( 'foo' ) ) ;
434434}
435-
436435{
437436 const target = new EventTarget ( ) ;
438437 strictEqual ( target . toString ( ) , '[object EventTarget]' ) ;
@@ -464,3 +463,16 @@ ok(EventTarget);
464463 } ) ;
465464 } ) ;
466465}
466+
467+ {
468+ strictEqual ( Event . NONE , 0 ) ;
469+ strictEqual ( Event . CAPTURING_PHASE , 1 ) ;
470+ strictEqual ( Event . AT_TARGET , 2 ) ;
471+ strictEqual ( Event . BUBBLING_PHASE , 3 ) ;
472+ strictEqual ( new Event ( 'foo' ) . eventPhase , Event . NONE ) ;
473+ const target = new EventTarget ( ) ;
474+ target . addEventListener ( 'foo' , common . mustCall ( ( e ) => {
475+ strictEqual ( e . eventPhase , Event . AT_TARGET ) ;
476+ } ) , { once : true } ) ;
477+ target . dispatchEvent ( new Event ( 'foo' ) ) ;
478+ }
You can’t perform that action at this time.
0 commit comments