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 <shishugi@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
lundibundi authored and jasnell committed Jun 24, 2020
1 parent 5e6ae9a commit 42d932c
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 42d932c

Please sign in to comment.