File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ const {
15
15
ERR_INVALID_ARG_TYPE ,
16
16
ERR_EVENT_RECURSION ,
17
17
ERR_OUT_OF_RANGE ,
18
+ ERR_MISSING_ARGS
18
19
}
19
20
} = require ( 'internal/errors' ) ;
20
21
@@ -44,6 +45,9 @@ class Event {
44
45
45
46
46
47
constructor ( type , options ) {
48
+ if ( arguments . length === 0 ) {
49
+ throw new ERR_MISSING_ARGS ( 'type' ) ;
50
+ }
47
51
if ( options != null && typeof options !== 'object' )
48
52
throw new ERR_INVALID_ARG_TYPE ( 'options' , 'object' , options ) ;
49
53
const { cancelable, bubbles, composed } = { ...options } ;
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ ok(EventTarget);
29
29
strictEqual ( ev . defaultPrevented , false ) ;
30
30
strictEqual ( typeof ev . timeStamp , 'number' ) ;
31
31
32
+ // Compatibility properties with the DOM
32
33
deepStrictEqual ( ev . composedPath ( ) , [ ] ) ;
33
34
strictEqual ( ev . returnValue , true ) ;
34
35
strictEqual ( ev . bubbles , false ) ;
@@ -40,7 +41,15 @@ ok(EventTarget);
40
41
ev . preventDefault ( ) ;
41
42
strictEqual ( ev . defaultPrevented , false ) ;
42
43
}
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
+ }
44
53
{
45
54
const ev = new Event ( 'foo' , { cancelable : true } ) ;
46
55
strictEqual ( ev . type , 'foo' ) ;
You can’t perform that action at this time.
0 commit comments