diff options
Diffstat (limited to 'ext/web/02_event.js')
-rw-r--r-- | ext/web/02_event.js | 78 |
1 files changed, 31 insertions, 47 deletions
diff --git a/ext/web/02_event.js b/ext/web/02_event.js index 859da2121..d59a897a6 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -122,20 +122,6 @@ const isTrusted = ObjectGetOwnPropertyDescriptor({ }, }, "isTrusted").get; -webidl.converters.EventInit = webidl.createDictionaryConverter("EventInit", [{ - key: "bubbles", - defaultValue: false, - converter: webidl.converters.boolean, -}, { - key: "cancelable", - defaultValue: false, - converter: webidl.converters.boolean, -}, { - key: "composed", - defaultValue: false, - converter: webidl.converters.boolean, -}]); - const _attributes = Symbol("[[attributes]]"); const _canceledFlag = Symbol("[[canceledFlag]]"); const _stopPropagationFlag = Symbol("[[stopPropagationFlag]]"); @@ -161,36 +147,7 @@ class Event { this[_isTrusted] = false; this[_path] = []; - if (!eventInitDict[_skipInternalInit]) { - webidl.requiredArguments( - arguments.length, - 1, - "Failed to construct 'Event'", - ); - type = webidl.converters.DOMString( - type, - "Failed to construct 'Event'", - "Argument 1", - ); - const eventInit = webidl.converters.EventInit( - eventInitDict, - "Failed to construct 'Event'", - "Argument 2", - ); - this[_attributes] = { - type, - ...eventInit, - currentTarget: null, - eventPhase: Event.NONE, - target: null, - timeStamp: DateNow(), - }; - // [LegacyUnforgeable] - ReflectDefineProperty(this, "isTrusted", { - enumerable: true, - get: isTrusted, - }); - } else { + if (eventInitDict?.[_skipInternalInit]) { this[_attributes] = { type, data: eventInitDict.data ?? null, @@ -202,10 +159,30 @@ class Event { target: null, timeStamp: 0, }; - // TODO(@littledivy): Not spec compliant but performance is hurt badly - // for users of `_skipInternalInit`. - this.isTrusted = false; + return; } + + webidl.requiredArguments( + arguments.length, + 1, + "Failed to construct 'Event'", + ); + type = webidl.converters.DOMString( + type, + "Failed to construct 'Event'", + "Argument 1", + ); + + this[_attributes] = { + type, + bubbles: !!eventInitDict.bubbles, + cancelable: !!eventInitDict.cancelable, + composed: !!eventInitDict.composed, + currentTarget: null, + eventPhase: Event.NONE, + target: null, + timeStamp: DateNow(), + }; } [SymbolFor("Deno.privateCustomInspect")](inspect) { @@ -435,6 +412,13 @@ class Event { } } +// Not spec compliant. The spec defines it as [LegacyUnforgeable] +// but doing so has a big performance hit +ReflectDefineProperty(Event.prototype, "isTrusted", { + enumerable: true, + get: isTrusted, +}); + function defineEnumerableProps( Ctor, props, |