Skip to content

Commit 6cf3af6

Browse files
committed
lib: define Event.isTrusted in the prototype
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
1 parent ab89428 commit 6cf3af6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/internal/event_target.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ class Event {
119119
isTrustedSet.add(this);
120120
}
121121

122-
// isTrusted is special (LegacyUnforgeable)
123-
ObjectDefineProperty(this, 'isTrusted', isTrustedDescriptor);
124122
this[kTarget] = null;
125123
this[kIsBeingDispatched] = false;
126124
}
@@ -343,6 +341,11 @@ ObjectDefineProperties(
343341
eventPhase: kEnumerableProperty,
344342
cancelBubble: kEnumerableProperty,
345343
stopPropagation: kEnumerableProperty,
344+
// Don't conform to the spec with isTrusted. The spec defines it as
345+
// LegacyUnforgeable but defining it in the constructor has a big
346+
// performance impact and the property doesn't seem to be useful outside of
347+
// browsers.
348+
isTrusted: isTrustedDescriptor,
346349
});
347350

348351
function isCustomEvent(value) {

0 commit comments

Comments
 (0)