Skip to content

Commit e90fbb1

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

File tree

3 files changed

+44
-37
lines changed

3 files changed

+44
-37
lines changed

lib/internal/event_target.js

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -349,32 +349,37 @@ ObjectDefineProperties(
349349
isTrusted: isTrustedDescriptor,
350350
});
351351

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

379384
function isCustomEvent(value) {
380385
return isEvent(value) && (value?.[kDetail] !== undefined);

test/parallel/test-event-target.js

Lines changed: 13 additions & 0 deletions
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+
}

test/parallel/test-event.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)