Skip to content
Prev Previous commit
Next Next commit
events: fix depth in customInspectSymbol and clean up
  • Loading branch information
lundibundi authored and jasnell committed Jun 21, 2020
commit 8a220fc7ea02b0be4bb89efd1b02994250cb69e0
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