Skip to content

Commit e867c32

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

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/internal/event_target.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,33 @@ ObjectDefineProperties(
354354
isTrusted: isTrustedDescriptor,
355355
});
356356

357+
Object.defineProperties(Event, {
358+
NONE: {
359+
writable: false,
360+
configurable: false,
361+
enumerable: true,
362+
value: 0,
363+
},
364+
CAPTURING_PHASE: {
365+
writable: false,
366+
configurable: false,
367+
enumerable: true,
368+
value: 1,
369+
},
370+
AT_TARGET: {
371+
writable: false,
372+
configurable: false,
373+
enumerable: true,
374+
value: 2,
375+
},
376+
BUBBLING_PHASE: {
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.js

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

0 commit comments

Comments
 (0)