File tree Expand file tree Collapse file tree 3 files changed +34
-8
lines changed Expand file tree Collapse file tree 3 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -2086,6 +2086,22 @@ added: v14.5.0
20862086
20872087This is not used in Node.js and is provided purely for completeness.
20882088
2089+ #### ` event.initEvent(type[, bubbles[, cancelable]]) `
2090+
2091+ <!-- YAML
2092+ added: REPLACEME
2093+ -->
2094+
2095+ > Stability: 3 - Legacy: The WHATWG spec considers it deprecated and users
2096+ > shouldn't use it at all.
2097+
2098+ * ` type ` {string}
2099+ * ` bubbles ` {boolean}
2100+ * ` cancelable ` {boolean}
2101+
2102+ Redundant with event constructors and incapable of setting ` composed ` .
2103+ This is not used in Node.js and is provided purely for completeness.
2104+
20892105#### ` event.isTrusted `
20902106
20912107<!-- YAML
Original file line number Diff line number Diff line change @@ -123,6 +123,23 @@ class Event {
123123 this [ kIsBeingDispatched ] = false ;
124124 }
125125
126+ /**
127+ * @param {string } type
128+ * @param {boolean } [bubbles]
129+ * @param {boolean } [cancelable]
130+ */
131+ initEvent ( type , bubbles = false , cancelable = false ) {
132+ if ( arguments . length === 0 )
133+ throw new ERR_MISSING_ARGS ( 'type' ) ;
134+
135+ if ( this [ kIsBeingDispatched ] ) {
136+ return ;
137+ }
138+ this [ kType ] = `${ type } ` ;
139+ this . #bubbles = ! ! bubbles ;
140+ this . #cancelable = ! ! cancelable ;
141+ }
142+
126143 [ customInspectSymbol ] ( depth , options ) {
127144 if ( ! isEvent ( this ) )
128145 throw new ERR_INVALID_THIS ( 'Event' ) ;
@@ -307,6 +324,7 @@ ObjectDefineProperties(
307324 configurable : true ,
308325 value : 'Event' ,
309326 } ,
327+ initEvent : kEnumerableProperty ,
310328 stopImmediatePropagation : kEnumerableProperty ,
311329 preventDefault : kEnumerableProperty ,
312330 target : kEnumerableProperty ,
Original file line number Diff line number Diff line change 88 ]
99 }
1010 },
11- "Event-constructors.any.js" : {
12- "fail" : {
13- "expected" : [
14- " Untitled 3" ,
15- " Untitled 4"
16- ]
17- }
18- },
1911 "Event-dispatch-listener-order.window.js" : {
2012 "skip" : " document is not defined"
2113 },
You can’t perform that action at this time.
0 commit comments