mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 21:24:48 +00:00
fix: Expose ErrorEvent globally (#5222)
This commit is contained in:
parent
32aeec9630
commit
d16c7394cb
4 changed files with 73 additions and 31 deletions
68
cli/js/web/error_event.ts
Normal file
68
cli/js/web/error_event.ts
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { EventImpl as Event } from "./event.ts";
|
||||
import { defineEnumerableProps } from "./util.ts";
|
||||
|
||||
export class ErrorEventImpl extends Event implements ErrorEvent {
|
||||
#message: string;
|
||||
#filename: string;
|
||||
#lineno: number;
|
||||
#colno: number;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
#error: any;
|
||||
|
||||
get message(): string {
|
||||
return this.#message;
|
||||
}
|
||||
get filename(): string {
|
||||
return this.#filename;
|
||||
}
|
||||
get lineno(): number {
|
||||
return this.#lineno;
|
||||
}
|
||||
get colno(): number {
|
||||
return this.#colno;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
get error(): any {
|
||||
return this.#error;
|
||||
}
|
||||
|
||||
constructor(
|
||||
type: string,
|
||||
{
|
||||
bubbles,
|
||||
cancelable,
|
||||
composed,
|
||||
message = "",
|
||||
filename = "",
|
||||
lineno = 0,
|
||||
colno = 0,
|
||||
error = null,
|
||||
}: ErrorEventInit = {}
|
||||
) {
|
||||
super(type, {
|
||||
bubbles: bubbles,
|
||||
cancelable: cancelable,
|
||||
composed: composed,
|
||||
});
|
||||
|
||||
this.#message = message;
|
||||
this.#filename = filename;
|
||||
this.#lineno = lineno;
|
||||
this.#colno = colno;
|
||||
this.#error = error;
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag](): string {
|
||||
return "ErrorEvent";
|
||||
}
|
||||
}
|
||||
|
||||
defineEnumerableProps(ErrorEventImpl, [
|
||||
"message",
|
||||
"filename",
|
||||
"lineno",
|
||||
"colno",
|
||||
"error",
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue