Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da9ebaf

Browse filesBrowse files
santigimenoMylesBorins
authored andcommitted
lib: predeclare Event.isTrusted prop descriptor
It improves Event creation performance. PR-URL: #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>
1 parent 35570e9 commit da9ebaf
Copy full SHA for da9ebaf

File tree

Expand file treeCollapse file tree

1 file changed

+8
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-6
lines changed
Open diff view settings
Collapse file

‎lib/internal/event_target.js‎

Copy file name to clipboardExpand all lines: lib/internal/event_target.js
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ const isTrusted = ObjectGetOwnPropertyDescriptor({
7878
}
7979
}, 'isTrusted').get;
8080

81+
const isTrustedDescriptor = {
82+
__proto__: null,
83+
configurable: false,
84+
enumerable: true,
85+
get: isTrusted,
86+
};
87+
8188
function isEvent(value) {
8289
return typeof value?.[kType] === 'string';
8390
}
@@ -113,12 +120,7 @@ class Event {
113120
}
114121

115122
// isTrusted is special (LegacyUnforgeable)
116-
ObjectDefineProperty(this, 'isTrusted', {
117-
__proto__: null,
118-
get: isTrusted,
119-
enumerable: true,
120-
configurable: false
121-
});
123+
ObjectDefineProperty(this, 'isTrusted', isTrustedDescriptor);
122124
this[kTarget] = null;
123125
this[kIsBeingDispatched] = false;
124126
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.