Skip to content

Commit 53502c7

Browse files
lib: event static properties non writable and configurable
The idl definition for Event makes the properties constant this means that they shouldn't be configurable and writable. However, they were, and this commit fixes that. Fixes: #50417
1 parent 6431c65 commit 53502c7

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

lib/internal/event_target.js

+32-5
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,6 @@ class Event {
314314
throw new ERR_INVALID_THIS('Event');
315315
this.#propagationStopped = true;
316316
}
317-
318-
static NONE = 0;
319-
static CAPTURING_PHASE = 1;
320-
static AT_TARGET = 2;
321-
static BUBBLING_PHASE = 3;
322317
}
323318

324319
ObjectDefineProperties(
@@ -354,6 +349,38 @@ ObjectDefineProperties(
354349
isTrusted: isTrustedDescriptor,
355350
});
356351

352+
ObjectDefineProperties(
353+
Event, {
354+
NONE: {
355+
__proto__: null,
356+
writable: false,
357+
configurable: false,
358+
enumerable: true,
359+
value: 0,
360+
},
361+
CAPTURING_PHASE: {
362+
__proto__: null,
363+
writable: false,
364+
configurable: false,
365+
enumerable: true,
366+
value: 1,
367+
},
368+
AT_TARGET: {
369+
__proto__: null,
370+
writable: false,
371+
configurable: false,
372+
enumerable: true,
373+
value: 2,
374+
},
375+
BUBBLING_PHASE: {
376+
__proto__: null,
377+
writable: false,
378+
configurable: false,
379+
enumerable: true,
380+
value: 3,
381+
},
382+
});
383+
357384
function isCustomEvent(value) {
358385
return isEvent(value) && (value?.[kDetail] !== undefined);
359386
}

test/parallel/test-event-target.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
const props = ['NONE', 'CAPTURING_PHASE', 'AT_TARGET', 'BUBBLING_PHASE'];
7+
8+
for (const prop of props) {
9+
const desc = Object.getOwnPropertyDescriptor(Event, prop);
10+
assert.strictEqual(desc.writable, false);
11+
assert.strictEqual(desc.configurable, false);
12+
assert.strictEqual(desc.enumerable, true);
13+
}

0 commit comments

Comments
 (0)