mirror of
https://github.com/denoland/deno.git
synced 2024-11-01 09:24:20 -04:00
d43b43ca78
Instead of using core/snapshot_creator.rs, instead two crates are introduced which allow building the snapshot during build.rs. Rollup is removed and replaced with our own bundler. This removes the Node build dependency. Modules in //js now use Deno-style imports with file extensions, rather than Node style extensionless imports. This improves incremental build time when changes are made to //js files by about 40 seconds.
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
|
import * as domTypes from "./dom_types.ts";
|
|
import * as event from "./event.ts";
|
|
import { getPrivateValue, requiredArguments } from "./util.ts";
|
|
|
|
// WeakMaps are recommended for private attributes (see MDN link below)
|
|
// https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Add-on_SDK/Guides/Contributor_s_Guide/Private_Properties#Using_WeakMaps
|
|
export const customEventAttributes = new WeakMap();
|
|
|
|
export class CustomEventInit extends event.EventInit
|
|
implements domTypes.CustomEventInit {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
detail: any;
|
|
|
|
constructor({
|
|
bubbles = false,
|
|
cancelable = false,
|
|
composed = false,
|
|
detail = null
|
|
}: domTypes.CustomEventInit) {
|
|
super({ bubbles, cancelable, composed });
|
|
this.detail = detail;
|
|
}
|
|
}
|
|
|
|
export class CustomEvent extends event.Event implements domTypes.CustomEvent {
|
|
constructor(
|
|
type: string,
|
|
customEventInitDict: domTypes.CustomEventInit = {}
|
|
) {
|
|
requiredArguments("CustomEvent", arguments.length, 1);
|
|
super(type, customEventInitDict);
|
|
const { detail = null } = customEventInitDict;
|
|
customEventAttributes.set(this, { detail });
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
get detail(): any {
|
|
return getPrivateValue(this, customEventAttributes, "detail");
|
|
}
|
|
|
|
initCustomEvent(
|
|
type: string,
|
|
bubbles?: boolean,
|
|
cancelable?: boolean,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
detail?: any
|
|
): void {
|
|
if (this.dispatched) {
|
|
return;
|
|
}
|
|
|
|
customEventAttributes.set(this, { detail });
|
|
}
|
|
|
|
get [Symbol.toStringTag](): string {
|
|
return "CustomEvent";
|
|
}
|
|
}
|
|
|
|
/** Built-in objects providing `get` methods for our
|
|
* interceptable JavaScript operations.
|
|
*/
|
|
Reflect.defineProperty(CustomEvent.prototype, "detail", { enumerable: true });
|