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
|
@ -11,6 +11,7 @@ import { TextDecoder, TextEncoder } from "./text_encoding.ts";
|
|||
/*
|
||||
import { blobURLMap } from "./web/url.ts";
|
||||
*/
|
||||
import { ErrorEventImpl as ErrorEvent } from "./error_event.ts";
|
||||
import { EventImpl as Event } from "./event.ts";
|
||||
import { EventTargetImpl as EventTarget } from "./event_target.ts";
|
||||
|
||||
|
@ -41,36 +42,6 @@ export class MessageEvent extends Event {
|
|||
}
|
||||
}
|
||||
|
||||
export interface ErrorEventInit extends EventInit {
|
||||
message?: string;
|
||||
filename?: string;
|
||||
lineno?: number;
|
||||
colno?: number;
|
||||
error?: any;
|
||||
}
|
||||
|
||||
export class ErrorEvent extends Event {
|
||||
readonly message: string;
|
||||
readonly filename: string;
|
||||
readonly lineno: number;
|
||||
readonly colno: number;
|
||||
readonly error: any;
|
||||
|
||||
constructor(type: string, eventInitDict?: ErrorEventInit) {
|
||||
super(type, {
|
||||
bubbles: eventInitDict?.bubbles ?? false,
|
||||
cancelable: eventInitDict?.cancelable ?? false,
|
||||
composed: eventInitDict?.composed ?? false,
|
||||
});
|
||||
|
||||
this.message = eventInitDict?.message ?? "";
|
||||
this.filename = eventInitDict?.filename ?? "";
|
||||
this.lineno = eventInitDict?.lineno ?? 0;
|
||||
this.colno = eventInitDict?.colno ?? 0;
|
||||
this.error = eventInitDict?.error ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
function encodeMessage(data: any): Uint8Array {
|
||||
const dataJson = JSON.stringify(data);
|
||||
return encoder.encode(dataJson);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue