File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -412,6 +412,9 @@ function validateListener(listener) {
412
412
}
413
413
414
414
function validateEventListenerOptions ( options ) {
415
+ if ( typeof options === 'boolean' ) {
416
+ options = { capture : options } ;
417
+ }
415
418
if ( options == null || typeof options !== 'object' )
416
419
throw new ERR_INVALID_ARG_TYPE ( 'options' , 'object' , options ) ;
417
420
const {
Original file line number Diff line number Diff line change @@ -151,7 +151,14 @@ const ev = new Event('foo');
151
151
eventTarget . addEventListener ( 'foo' , ( event ) => event . preventDefault ( ) ) ;
152
152
ok ( ! eventTarget . dispatchEvent ( event ) ) ;
153
153
}
154
-
154
+ {
155
+ // Adding event listeners with a boolean useCapture
156
+ const eventTarget = new EventTarget ( ) ;
157
+ const event = new Event ( 'foo' ) ;
158
+ const fn = common . mustCall ( ( event ) => strictEqual ( event . type , 'foo' ) ) ;
159
+ eventTarget . addEventListener ( 'foo' , fn , false ) ;
160
+ eventTarget . dispatchEvent ( event ) ;
161
+ }
155
162
{
156
163
const eventTarget = new NodeEventTarget ( ) ;
157
164
strictEqual ( eventTarget . listenerCount ( 'foo' ) , 0 ) ;
You can’t perform that action at this time.
0 commit comments