diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index bccb2e0edc6a0d..21d3774a586a7f 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -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), }; }