summaryrefslogtreecommitdiff
path: root/cli/js/web/custom_event.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/web/custom_event.ts')
-rw-r--r--cli/js/web/custom_event.ts40
1 files changed, 12 insertions, 28 deletions
diff --git a/cli/js/web/custom_event.ts b/cli/js/web/custom_event.ts
index 418b7ea34..ea76d2c94 100644
--- a/cli/js/web/custom_event.ts
+++ b/cli/js/web/custom_event.ts
@@ -1,44 +1,28 @@
// 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 { EventImpl as Event } from "./event.ts";
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;
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export class CustomEventImpl<T = any> extends Event implements CustomEvent {
+ #detail: T;
- constructor(
- type: string,
- customEventInitDict: domTypes.CustomEventInit = {}
- ) {
- super(type, customEventInitDict);
+ constructor(type: string, eventInitDict: CustomEventInit<T> = {}) {
+ super(type, eventInitDict);
requiredArguments("CustomEvent", arguments.length, 1);
- const { detail = null } = customEventInitDict;
- this.#detail = detail;
+ const { detail } = eventInitDict;
+ this.#detail = detail as T;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- get detail(): any {
+ get detail(): T {
return this.#detail;
}
- initCustomEvent(
- _type: string,
- _bubbles?: boolean,
- _cancelable?: boolean,
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- detail?: any
- ): void {
- if (this.dispatched) {
- return;
- }
-
- this.#detail = detail;
- }
-
get [Symbol.toStringTag](): string {
return "CustomEvent";
}
}
-Reflect.defineProperty(CustomEvent.prototype, "detail", { enumerable: true });
+Reflect.defineProperty(CustomEventImpl.prototype, "detail", {
+ enumerable: true,
+});