1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/cli/js/web/custom_event.ts

30 lines
846 B
TypeScript
Raw Normal View History

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2020-07-06 21:45:39 -04:00
import { EventImpl as Event } from "./event.ts";
import { requiredArguments } from "./util.ts";
2019-01-23 07:20:53 -05:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export class CustomEventImpl<T = any> extends Event implements CustomEvent {
2020-07-06 21:45:39 -04:00
readonly #detail: T;
constructor(type: string, eventInitDict: CustomEventInit<T> = {}) {
super(type, eventInitDict);
requiredArguments("CustomEvent", arguments.length, 1);
const { detail } = eventInitDict;
this.#detail = detail as T;
2019-01-23 07:20:53 -05:00
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get detail(): T {
return this.#detail;
2019-01-23 07:20:53 -05:00
}
get [Symbol.toStringTag](): string {
return "CustomEvent";
}
2019-01-23 07:20:53 -05:00
}
Reflect.defineProperty(CustomEventImpl.prototype, "detail", {
enumerable: true,
});