Skip to content

Commit

Permalink
lib: Event static properties non configurable and writable
Browse files Browse the repository at this point in the history
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: nodejs#50417
  • Loading branch information
BenzeneAlcohol committed Oct 27, 2023
1 parent e867c32 commit c4685ee
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -354,32 +349,32 @@ ObjectDefineProperties(
isTrusted: isTrustedDescriptor,
});

Object.defineProperties(Event, {
NONE: {
writable: false,
configurable: false,
enumerable: true,
value: 0,
},
CAPTURING_PHASE: {
writable: false,
configurable: false,
enumerable: true,
value: 1,
},
AT_TARGET: {
writable: false,
configurable: false,
enumerable: true,
value: 2,
},
BUBBLING_PHASE: {
writable: false,
configurable: false,
enumerable: true,
value: 3,
}
});
Object.defineProperties(Event, {
NONE: {
writable: false,
configurable: false,
enumerable: true,
value: 0,
},
CAPTURING_PHASE: {
writable: false,
configurable: false,
enumerable: true,
value: 1,
},
AT_TARGET: {
writable: false,
configurable: false,
enumerable: true,
value: 2,
},
BUBBLING_PHASE: {
writable: false,
configurable: false,
enumerable: true,
value: 3,
}
});

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

0 comments on commit c4685ee

Please sign in to comment.