fix: bubble alias

pull/8356/head
Fred Martini 4 years ago
parent 719f3a6b20
commit 617b9116ba

@ -147,7 +147,7 @@ export function hasContext(key): boolean {
}
function start_bubble(type: string, bubble: Bubble, callback: Callback) {
const dispose = bubble.f(type, callback.f, callback.o);
const dispose = bubble.f(callback.f, callback.o, type);
if (dispose) {
bubble.r.set(callback, dispose);
}
@ -205,9 +205,9 @@ export function onEventListener(type: string, fn: CallbackFactory) {
export function bubble(component: SvelteComponent, listen_func: Function, node: EventTarget|SvelteComponent, type: string, typeName: string = type): Function {
return add_bubble(component, type, (eventType, callback, options) => {
let typeToListen: string;
if (type === '*') {
return add_bubble(component, type, (callback, options, eventType) => {
let typeToListen: string = null;
if (typeName === '*') {
typeToListen = eventType;
} else if (typeName.startsWith('*')) {
@ -221,13 +221,14 @@ export function bubble(component: SvelteComponent, listen_func: Function, node:
typeToListen = eventType.substring(len-1);
}
}
} else if (eventType === typeName) {
typeToListen = type;
}
if (typeToListen) {
return listen_func(node, typeToListen, callback, options);
}
});
}
return add_bubble(component, typeName, (callback, options) => {
return listen_func(node, type, callback, options);
});
}
export function listen_comp(comp: SvelteComponent, event: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | EventListenerOptions, wrappers?: Function[]) {

@ -25,7 +25,7 @@ export interface Callback {
o?: boolean | AddEventListenerOptions | EventListenerOptions;
}
export type CallbackFactory = (type: string, callback: EventListener, options: boolean | AddEventListenerOptions | EventListenerOptions | undefined) => Function|void;
export type CallbackFactory = (callback: EventListener, options: boolean | AddEventListenerOptions | EventListenerOptions | undefined, type: string) => Function|void;
export interface Bubble {
f: CallbackFactory;

Loading…
Cancel
Save