Skip to content

Commit

Permalink
events: fix depth in customInspectSymbol and clean up
Browse files Browse the repository at this point in the history
PR-URL: #34015
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
lundibundi authored and codebytere committed Jun 27, 2020
1 parent 6ce3293 commit 0f0f4e0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

const {
ArrayFrom,
Boolean,
Error,
Map,
NumberIsInteger,
Object,
Set,
Symbol,
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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) {
Expand All @@ -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)}`;
Expand Down Expand Up @@ -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),
};
}

Expand Down

0 comments on commit 0f0f4e0

Please sign in to comment.