We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54f58e2 commit 42e1f72Copy full SHA for 42e1f72
2 files changed
lib/internal/event_target.js
@@ -867,8 +867,6 @@ class EventTarget {
867
return new CustomEvent(type, { detail: nodeValue });
868
}
869
[customInspectSymbol](depth, options) {
870
- if (!isEventTarget(this))
871
- throw new ERR_INVALID_THIS('EventTarget');
872
const name = this.constructor.name;
873
if (depth < 0)
874
return name;
test/parallel/test-eventtarget-custom-inspect-does-not-throw.js
@@ -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