| 1 |
/** |
| 2 |
* @license |
| 3 |
* Copyright 2022 Google LLC |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
import {ExternalCustomEvent, ExternalClass} from './custom-event.js'; |
| 8 |
|
| 9 |
export class LocalCustomEvent extends Event { |
| 10 |
message: string; |
| 11 |
constructor(message) { |
| 12 |
super('local-custom-event'); |
| 13 |
this.message = message; |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* A cool custom element. |
| 19 |
* |
| 20 |
* @fires event |
| 21 |
* @fires event-two This is an event |
| 22 |
* @fires event-three - This is another event |
| 23 |
* @fires typed-event {MouseEvent} |
| 24 |
* @fires typed-event-two {MouseEvent} This is a typed event |
| 25 |
* @fires typed-event-three {MouseEvent} - This is another typed event |
| 26 |
* @fires external-custom-event {ExternalCustomEvent} - External custom event |
| 27 |
* @fires local-custom-event {LocalCustomEvent} - Local custom event |
| 28 |
* @fires generic-custom-event {CustomEvent<ExternalClass>} - Local custom event |
| 29 |
* @fires inline-detail-custom-event {CustomEvent<{ event: MouseEvent; more: { impl: ExternalClass; }; }>} |
| 30 |
* |
| 31 |
* @comment malformed fires tag: |
| 32 |
* |
| 33 |
* @fires |
| 34 |
*/ |
| 35 |
export class ElementA extends HTMLElement { |
| 36 |
fireExternalEvent() { |
| 37 |
this.dispatchEvent(new ExternalCustomEvent('external')); |
| 38 |
} |
| 39 |
fireLocalEvent() { |
| 40 |
this.dispatchEvent(new LocalCustomEvent('local')); |
| 41 |
} |
| 42 |
fireGenericEvent() { |
| 43 |
this.dispatchEvent( |
| 44 |
new CustomEvent<ExternalClass>('generic-custom-event', { |
| 45 |
detail: new ExternalClass(), |
| 46 |
}) |
| 47 |
); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
customElements.define('element-a', ElementA); |