Skip to content

Commit 0f0f4e0

Browse files
lundibundicodebytere
authored andcommitted
events: fix depth in customInspectSymbol and clean up
PR-URL: #34015 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 6ce3293 commit 0f0f4e0

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lib/internal/event_target.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
const {
44
ArrayFrom,
5+
Boolean,
56
Error,
67
Map,
8+
NumberIsInteger,
79
Object,
810
Set,
911
Symbol,
@@ -78,7 +80,7 @@ class Event {
7880
return name;
7981

8082
const opts = Object.assign({}, options, {
81-
dept: options.depth === null ? null : options.depth - 1
83+
depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth
8284
});
8385

8486
return `${name} ${inspect({
@@ -294,7 +296,7 @@ class EventTarget {
294296
this.#emitting.delete(event.type);
295297
event[kTarget] = undefined;
296298

297-
return event.defaultPrevented === true ? false : true;
299+
return event.defaultPrevented !== true;
298300
}
299301

300302
[customInspectSymbol](depth, options) {
@@ -303,7 +305,7 @@ class EventTarget {
303305
return name;
304306

305307
const opts = Object.assign({}, options, {
306-
dept: options.depth === null ? null : options.depth - 1
308+
depth: NumberIsInteger(options.depth) ? options.depth - 1 : options.depth
307309
});
308310

309311
return `${name} ${inspect({}, opts)}`;
@@ -429,15 +431,10 @@ function validateEventListenerOptions(options) {
429431
if (typeof options === 'boolean')
430432
return { capture: options };
431433
validateObject(options, 'options');
432-
const {
433-
once = false,
434-
capture = false,
435-
passive = false,
436-
} = options;
437434
return {
438-
once: !!once,
439-
capture: !!capture,
440-
passive: !!passive,
435+
once: Boolean(options.once),
436+
capture: Boolean(options.capture),
437+
passive: Boolean(options.passive),
441438
};
442439
}
443440

0 commit comments

Comments
 (0)