diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 0236f3a53c5276..660c2456cc02bc 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -314,11 +314,6 @@ class Event { throw new ERR_INVALID_THIS('Event'); this.#propagationStopped = true; } - - static NONE = 0; - static CAPTURING_PHASE = 1; - static AT_TARGET = 2; - static BUBBLING_PHASE = 3; } ObjectDefineProperties( @@ -354,6 +349,38 @@ ObjectDefineProperties( isTrusted: isTrustedDescriptor, }); +ObjectDefineProperties( + Event, { + NONE: { + __proto__: null, + writable: false, + configurable: false, + enumerable: true, + value: 0, + }, + CAPTURING_PHASE: { + __proto__: null, + writable: false, + configurable: false, + enumerable: true, + value: 1, + }, + AT_TARGET: { + __proto__: null, + writable: false, + configurable: false, + enumerable: true, + value: 2, + }, + BUBBLING_PHASE: { + __proto__: null, + writable: false, + configurable: false, + enumerable: true, + value: 3, + }, + }); + function isCustomEvent(value) { return isEvent(value) && (value?.[kDetail] !== undefined); } diff --git a/test/parallel/test-event-target.js b/test/parallel/test-event-target.js new file mode 100644 index 00000000000000..4490faeecfba6a --- /dev/null +++ b/test/parallel/test-event-target.js @@ -0,0 +1,13 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +const props = ['NONE', 'CAPTURING_PHASE', 'AT_TARGET', 'BUBBLING_PHASE']; + +for (const prop of props) { + const desc = Object.getOwnPropertyDescriptor(Event, prop); + assert.strictEqual(desc.writable, false); + assert.strictEqual(desc.configurable, false); + assert.strictEqual(desc.enumerable, true); +}