File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ class Event {
114
114
get bubbles ( ) { return this . #bubbles; }
115
115
get composed ( ) { return this . #composed; }
116
116
get eventPhase ( ) {
117
- return this [ kTarget ] ? 2 : 0 ; // Equivalent to AT_TARGET or NONE
117
+ return this [ kTarget ] ? Event . AT_TARGET : Event . NONE ;
118
118
}
119
119
get cancelBubble ( ) { return this . #propagationStopped; }
120
120
set cancelBubble ( value ) {
@@ -127,6 +127,10 @@ class Event {
127
127
}
128
128
129
129
get [ Symbol . toStringTag ] ( ) { return 'Event' ; }
130
+ static NONE = 0 ;
131
+ static CAPTURING_PHASE = 1 ;
132
+ static AT_TARGET = 2 ;
133
+ static BUBBLING_PHASE = 3 ;
130
134
}
131
135
132
136
// The listeners for an EventTarget are maintained as a linked list.
Original file line number Diff line number Diff line change @@ -432,10 +432,21 @@ ok(EventTarget);
432
432
target . removeEventListener ( 'foo' , a , { capture : false } ) ;
433
433
target . dispatchEvent ( new Event ( 'foo' ) ) ;
434
434
}
435
-
436
435
{
437
436
const target = new EventTarget ( ) ;
438
437
strictEqual ( target . toString ( ) , '[object EventTarget]' ) ;
439
438
const event = new Event ( '' ) ;
440
439
strictEqual ( event . toString ( ) , '[object Event]' ) ;
441
440
}
441
+ {
442
+ strictEqual ( Event . NONE , 0 ) ;
443
+ strictEqual ( Event . CAPTURING_PHASE , 1 ) ;
444
+ strictEqual ( Event . AT_TARGET , 2 ) ;
445
+ strictEqual ( Event . BUBBLING_PHASE , 3 ) ;
446
+ strictEqual ( new Event ( ) . eventPhase , Event . NONE ) ;
447
+ const target = new EventTarget ( ) ;
448
+ target . addEventListener ( 'foo' , common . mustCall ( ( e ) => {
449
+ strictEqual ( e . eventPhase , Event . AT_TARGET ) ;
450
+ } ) , { once : true } ) ;
451
+ target . dispatchEvent ( new Event ( 'foo' ) ) ;
452
+ }
You can’t perform that action at this time.
0 commit comments