events: remove eventtarget custom inspect branding

PR-URL: https://github.com/nodejs/node/pull/61128
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Efe
2025-12-22 17:14:56 +01:00
committed by GitHub
parent 472f586840
commit 416db75e42
2 changed files with 19 additions and 2 deletions

View File

@@ -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;

View File

@@ -0,0 +1,19 @@
'use strict';
require('../common');
const assert = require('assert');
const util = require('util');
const symbol = util.inspect.custom;
const eventTargetInspect = EventTarget.prototype[symbol];
const fakeEventTarget = {
[symbol]: eventTargetInspect,
someOtherField: 42
};
// Should not throw when calling the custom inspect method
const output = util.inspect(fakeEventTarget);
assert.strictEqual(typeof output, 'string');