Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,6 @@ class EventTarget {
return new CustomEvent(type, { detail: nodeValue });
}
[customInspectSymbol](depth, options) {
if (!isEventTarget(this))
throw new ERR_INVALID_THIS('EventTarget');
const name = this.constructor.name;
if (depth < 0)
return name;
Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-eventtarget-custom-inspect-does-not-throw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const assert = require('assert');
const util = require('util');

const symbol = util.inspect.custom;

const eventTargetInspect = EventTarget.prototype[symbol];

const fakeEventTarget = {
[symbol]: eventTargetInspect,
someOtherField: 42
};

assert.doesNotThrow(() => {
util.inspect(fakeEventTarget);
});
Comment on lines +15 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.doesNotThrow(() => {
util.inspect(fakeEventTarget);
});
util.inspect(fakeEventTarget);

Using assert.doesNotThrow() is discouraged and is prohibited by the linter.

Ideally, we can verify the output as well.