summaryrefslogtreecommitdiff
path: root/packages/webapi/src/lib/CustomEvent.ts
blob: 1269b72169c1fb291606b42fde478cf01e590daa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Event } from 'event-target-shim'
import * as _ from './utils'

class CustomEvent<
	TEventType extends string = string
> extends Event<TEventType> {
	constructor(type: TEventType, params?: CustomEventInit) {
		params = Object(params) as Required<CustomEventInit>

		super(type, params)

		if ('detail' in params) this.detail = params.detail
	}

	detail!: any
}

_.allowStringTag(CustomEvent)

export { CustomEvent }

interface CustomEventInit {
	bubbles?: boolean
	cancelable?: false
	detail?: any
}