mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
29 lines
846 B
TypeScript
29 lines
846 B
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { EventImpl as Event } from "./event.ts";
|
|
import { requiredArguments } from "./util.ts";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export class CustomEventImpl<T = any> extends Event implements CustomEvent {
|
|
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;
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
get detail(): T {
|
|
return this.#detail;
|
|
}
|
|
|
|
get [Symbol.toStringTag](): string {
|
|
return "CustomEvent";
|
|
}
|
|
}
|
|
|
|
Reflect.defineProperty(CustomEventImpl.prototype, "detail", {
|
|
enumerable: true,
|
|
});
|