diff options
Diffstat (limited to 'cli/js/web/custom_event.ts')
-rw-r--r-- | cli/js/web/custom_event.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/cli/js/web/custom_event.ts b/cli/js/web/custom_event.ts index 24a263baf..418b7ea34 100644 --- a/cli/js/web/custom_event.ts +++ b/cli/js/web/custom_event.ts @@ -1,32 +1,31 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import * as domTypes from "./dom_types.ts"; import * as event from "./event.ts"; -import { getPrivateValue, requiredArguments } from "./util.ts"; - -// WeakMaps are recommended for private attributes (see MDN link below) -// https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Add-on_SDK/Guides/Contributor_s_Guide/Private_Properties#Using_WeakMaps -export const customEventAttributes = new WeakMap(); +import { requiredArguments } from "./util.ts"; export class CustomEvent extends event.Event implements domTypes.CustomEvent { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + #detail: any; + constructor( type: string, customEventInitDict: domTypes.CustomEventInit = {} ) { - requiredArguments("CustomEvent", arguments.length, 1); super(type, customEventInitDict); + requiredArguments("CustomEvent", arguments.length, 1); const { detail = null } = customEventInitDict; - customEventAttributes.set(this, { detail }); + this.#detail = detail; } // eslint-disable-next-line @typescript-eslint/no-explicit-any get detail(): any { - return getPrivateValue(this, customEventAttributes, "detail"); + return this.#detail; } initCustomEvent( - type: string, - bubbles?: boolean, - cancelable?: boolean, + _type: string, + _bubbles?: boolean, + _cancelable?: boolean, // eslint-disable-next-line @typescript-eslint/no-explicit-any detail?: any ): void { @@ -34,7 +33,7 @@ export class CustomEvent extends event.Event implements domTypes.CustomEvent { return; } - customEventAttributes.set(this, { detail }); + this.#detail = detail; } get [Symbol.toStringTag](): string { |