Bubble svelte dev events (#5994)

pull/6454/head
Ava Johnson 3 years ago committed by GitHub
parent 7bf3f20dc3
commit 46fac828f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,7 +2,7 @@ import { custom_event, append, insert, detach, listen, attr } from './dom';
import { SvelteComponent } from './Component';
export function dispatch_dev<T=any>(type: string, detail?: T) {
document.dispatchEvent(custom_event(type, { version: '__VERSION__', ...detail }));
document.dispatchEvent(custom_event(type, { version: '__VERSION__', ...detail }, true));
}
export function append_dev(target: Node, node: Node) {

@ -521,9 +521,9 @@ export function toggle_class(element, name, toggle) {
element.classList[toggle ? 'add' : 'remove'](name);
}
export function custom_event<T=any>(type: string, detail?: T) {
export function custom_event<T=any>(type: string, detail?: T, bubbles: boolean = false) {
const e: CustomEvent<T> = document.createEvent('CustomEvent');
e.initCustomEvent(type, false, false, detail);
e.initCustomEvent(type, bubbles, false, detail);
return e;
}

Loading…
Cancel
Save