mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: predeclare Event.isTrusted prop descriptor
It improves Event creation performance. PR-URL: https://github.com/nodejs/node/pull/46527 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
@@ -78,6 +78,13 @@ const isTrusted = ObjectGetOwnPropertyDescriptor({
|
||||
}
|
||||
}, 'isTrusted').get;
|
||||
|
||||
const isTrustedDescriptor = {
|
||||
__proto__: null,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
get: isTrusted,
|
||||
};
|
||||
|
||||
function isEvent(value) {
|
||||
return typeof value?.[kType] === 'string';
|
||||
}
|
||||
@@ -113,12 +120,7 @@ class Event {
|
||||
}
|
||||
|
||||
// isTrusted is special (LegacyUnforgeable)
|
||||
ObjectDefineProperty(this, 'isTrusted', {
|
||||
__proto__: null,
|
||||
get: isTrusted,
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
ObjectDefineProperty(this, 'isTrusted', isTrustedDescriptor);
|
||||
this[kTarget] = null;
|
||||
this[kIsBeingDispatched] = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user