File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const {
1515 ERR_INVALID_ARG_TYPE ,
1616 ERR_EVENT_RECURSION ,
1717 ERR_OUT_OF_RANGE ,
18+ ERR_MISSING_ARGS
1819 }
1920} = require ( 'internal/errors' ) ;
2021
@@ -44,6 +45,9 @@ class Event {
4445
4546
4647 constructor ( type , options ) {
48+ if ( arguments . length === 0 ) {
49+ throw new ERR_MISSING_ARGS ( 'type' ) ;
50+ }
4751 if ( options != null && typeof options !== 'object' )
4852 throw new ERR_INVALID_ARG_TYPE ( 'options' , 'object' , options ) ;
4953 const { cancelable, bubbles, composed } = { ...options } ;
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ ok(EventTarget);
2929 strictEqual ( ev . defaultPrevented , false ) ;
3030 strictEqual ( typeof ev . timeStamp , 'number' ) ;
3131
32+ // Compatibility properties with the DOM
3233 deepStrictEqual ( ev . composedPath ( ) , [ ] ) ;
3334 strictEqual ( ev . returnValue , true ) ;
3435 strictEqual ( ev . bubbles , false ) ;
@@ -40,7 +41,15 @@ ok(EventTarget);
4041 ev . preventDefault ( ) ;
4142 strictEqual ( ev . defaultPrevented , false ) ;
4243}
43-
44+ {
45+ // No argument behavior - throw TypeError
46+ throws ( ( ) => {
47+ new Event ( ) ;
48+ } , TypeError ) ;
49+ // Too many arguments passed behavior - ignore additional arguments
50+ const ev = new Event ( 'foo' , { } , { } ) ;
51+ strictEqual ( ev . type , 'foo' ) ;
52+ }
4453{
4554 const ev = new Event ( 'foo' , { cancelable : true } ) ;
4655 strictEqual ( ev . type , 'foo' ) ;
You can’t perform that action at this time.
0 commit comments