Skip to content

Commit 416db75

Browse files
authored
events: remove eventtarget custom inspect branding
PR-URL: #61128 Reviewed-By: Aviv Keller <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 472f586 commit 416db75

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/internal/event_target.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,6 @@ class EventTarget {
867867
return new CustomEvent(type, { detail: nodeValue });
868868
}
869869
[customInspectSymbol](depth, options) {
870-
if (!isEventTarget(this))
871-
throw new ERR_INVALID_THIS('EventTarget');
872870
const name = this.constructor.name;
873871
if (depth < 0)
874872
return name;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const util = require('util');
6+
7+
const symbol = util.inspect.custom;
8+
9+
const eventTargetInspect = EventTarget.prototype[symbol];
10+
11+
const fakeEventTarget = {
12+
[symbol]: eventTargetInspect,
13+
someOtherField: 42
14+
};
15+
16+
// Should not throw when calling the custom inspect method
17+
const output = util.inspect(fakeEventTarget);
18+
19+
assert.strictEqual(typeof output, 'string');

0 commit comments

Comments
 (0)