-
-
Notifications
You must be signed in to change notification settings - Fork 35k
events: EventTarget use validators and small fix #33663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,10 @@ | |
|
|
||
| const { | ||
| ArrayFrom, | ||
| Boolean, | ||
| Error, | ||
| Map, | ||
| NumberIsInteger, | ||
| Object, | ||
| Set, | ||
| Symbol, | ||
|
|
@@ -78,7 +80,7 @@ class Event { | |
| return name; | ||
|
|
||
| const opts = Object.assign({}, options, { | ||
| dept: options.depth === null ? null : options.depth - 1 | ||
| depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth | ||
|
||
| }); | ||
|
|
||
| return `${name} ${inspect({ | ||
|
|
@@ -294,7 +296,7 @@ class EventTarget { | |
| this.#emitting.delete(event.type); | ||
| event[kTarget] = undefined; | ||
|
|
||
| return event.defaultPrevented === true ? false : true; | ||
| return event.defaultPrevented !== true; | ||
| } | ||
|
|
||
| [customInspectSymbol](depth, options) { | ||
|
|
@@ -303,7 +305,7 @@ class EventTarget { | |
| return name; | ||
|
|
||
| const opts = Object.assign({}, options, { | ||
| dept: options.depth === null ? null : options.depth - 1 | ||
| depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth | ||
| }); | ||
|
|
||
| return `${name} ${inspect({}, opts)}`; | ||
|
|
@@ -429,15 +431,10 @@ function validateEventListenerOptions(options) { | |
| if (typeof options === 'boolean') | ||
| return { capture: options }; | ||
| validateObject(options, 'options'); | ||
| const { | ||
| once = false, | ||
| capture = false, | ||
| passive = false, | ||
| } = options; | ||
| return { | ||
| once: !!once, | ||
| capture: !!capture, | ||
| passive: !!passive, | ||
| once: Boolean(options.once), | ||
| capture: Boolean(options.capture), | ||
| passive: Boolean(options.passive), | ||
| }; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, @BridgeAR shouldn't this return
this? (as well as the other one)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be ideal.
thiswill just letinspect()to properly know what to do.