diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2020-03-05 13:05:41 +0100 |
---|---|---|
committer | Bartek Iwańczuk <biwanczuk@gmail.com> | 2020-03-05 18:48:55 +0100 |
commit | 2e590072148c85bbc479ab49aa9556b0a2cfaff2 (patch) | |
tree | 89747e7b6762158e35f9120ca0ef0fa14991ae34 /cli/js/custom_event.ts | |
parent | 9b59ed7c7907c5f365e72b5c5a74114eb8ff1488 (diff) |
move Web APIs to cli/js/web/
Diffstat (limited to 'cli/js/custom_event.ts')
-rw-r--r-- | cli/js/custom_event.ts | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/cli/js/custom_event.ts b/cli/js/custom_event.ts deleted file mode 100644 index 2d94df56d..000000000 --- a/cli/js/custom_event.ts +++ /dev/null @@ -1,48 +0,0 @@ -// 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(); - -export class CustomEvent extends event.Event implements domTypes.CustomEvent { - constructor( - type: string, - customEventInitDict: domTypes.CustomEventInit = {} - ) { - requiredArguments("CustomEvent", arguments.length, 1); - super(type, customEventInitDict); - const { detail = null } = customEventInitDict; - customEventAttributes.set(this, { detail }); - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - get detail(): any { - return getPrivateValue(this, customEventAttributes, "detail"); - } - - initCustomEvent( - type: string, - bubbles?: boolean, - cancelable?: boolean, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - detail?: any - ): void { - if (this.dispatched) { - return; - } - - customEventAttributes.set(this, { detail }); - } - - get [Symbol.toStringTag](): string { - return "CustomEvent"; - } -} - -/** Built-in objects providing `get` methods for our - * interceptable JavaScript operations. - */ -Reflect.defineProperty(CustomEvent.prototype, "detail", { enumerable: true }); |