@@ -35,12 +35,13 @@ class Event {
35
35
#cancelable = false ;
36
36
#timestamp = perf_hooks . performance . now ( ) ;
37
37
38
- // Neither of these are currently used in the Node.js implementation
38
+ // None of these are currently used in the Node.js implementation
39
39
// of EventTarget because there is no concept of bubbling or
40
40
// composition. We preserve their values in Event but they are
41
41
// non-ops and do not carry any semantics in Node.js
42
42
#bubbles = false ;
43
43
#composed = false ;
44
+ #propagationStopped = false ;
44
45
45
46
46
47
constructor ( type , options ) {
@@ -51,6 +52,7 @@ class Event {
51
52
this . #bubbles = ! ! bubbles ;
52
53
this . #composed = ! ! composed ;
53
54
this . #type = `${ type } ` ;
55
+ this . #propagationStopped = false ;
54
56
// isTrusted is special (LegacyUnforgeable)
55
57
Object . defineProperty ( this , 'isTrusted' , {
56
58
get ( ) { return false ; } ,
@@ -109,11 +111,14 @@ class Event {
109
111
get eventPhase ( ) {
110
112
return this [ kTarget ] ? 2 : 0 ; // Equivalent to AT_TARGET or NONE
111
113
}
112
- cancelBubble ( ) {
113
- // Non-op in Node.js. Alias for stopPropagation
114
+ get cancelBubble ( ) { return this . #propagationStopped; }
115
+ set cancelBubble ( value ) {
116
+ if ( value ) {
117
+ this . stopPropagation ( ) ;
118
+ }
114
119
}
115
120
stopPropagation ( ) {
116
- // Non-op in Node.js
121
+ this . #propagationStopped = true ;
117
122
}
118
123
119
124
get [ Symbol . toStringTag ] ( ) { return 'Event' ; }
0 commit comments