1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 00:21:05 -05:00

perf(web): optimize Event constructor (#12231)

Assign in constructor instead of using class initializers which are currently ~10x slower
This commit is contained in:
Aaron O'Mullan 2021-09-26 20:41:05 +02:00 committed by GitHub
parent 1749e79f97
commit 5788f2e082
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -135,16 +135,15 @@
const _path = Symbol("[[path]]");
class Event {
[_attributes] = {};
[_canceledFlag] = false;
[_stopPropagationFlag] = false;
[_stopImmediatePropagationFlag] = false;
[_inPassiveListener] = false;
[_dispatched] = false;
[_isTrusted] = false;
[_path] = [];
constructor(type, eventInitDict = {}) {
this[_canceledFlag] = false;
this[_stopPropagationFlag] = false;
this[_stopImmediatePropagationFlag] = false;
this[_inPassiveListener] = false;
this[_dispatched] = false;
this[_isTrusted] = false;
this[_path] = [];
webidl.requiredArguments(arguments.length, 1, {
prefix: "Failed to construct 'Event'",
});