Skip to content

Commit

Permalink
lib: define Event.isTrusted in the prototype
Browse files Browse the repository at this point in the history
Don't conform to the spec with isTrusted. The spec defines it as
`LegacyUnforgeable` but defining it in the constructor has a big
performance impact and the property doesn't seem to be useful outside of
browsers.

Refs: nodejs/performance#32
  • Loading branch information
santigimeno committed Mar 6, 2023
1 parent ab89428 commit 6cf3af6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/internal/event_target.js
Expand Up @@ -119,8 +119,6 @@ class Event {
isTrustedSet.add(this);
}

// isTrusted is special (LegacyUnforgeable)
ObjectDefineProperty(this, 'isTrusted', isTrustedDescriptor);
this[kTarget] = null;
this[kIsBeingDispatched] = false;
}
Expand Down Expand Up @@ -343,6 +341,11 @@ ObjectDefineProperties(
eventPhase: kEnumerableProperty,
cancelBubble: kEnumerableProperty,
stopPropagation: kEnumerableProperty,
// Don't conform to the spec with isTrusted. The spec defines it as
// LegacyUnforgeable but defining it in the constructor has a big
// performance impact and the property doesn't seem to be useful outside of
// browsers.
isTrusted: isTrustedDescriptor,
});

function isCustomEvent(value) {
Expand Down

0 comments on commit 6cf3af6

Please sign in to comment.