|
|
|
@ -36,6 +36,8 @@ export function createEventDispatcher<
|
|
|
|
const callbacks = component.$$.callbacks[type];
|
|
|
|
const callbacks = component.$$.callbacks[type];
|
|
|
|
const eventBinding = component.eventBindings && Object.prototype.hasOwnProperty.call(component.eventBindings, type) ? component.eventBindings[type] : undefined;
|
|
|
|
const eventBinding = component.eventBindings && Object.prototype.hasOwnProperty.call(component.eventBindings, type) ? component.eventBindings[type] : undefined;
|
|
|
|
const catchAll = component.eventBindings && Object.prototype.hasOwnProperty.call(component.eventBindings, '*') ? component.eventBindings['*'] : undefined;
|
|
|
|
const catchAll = component.eventBindings && Object.prototype.hasOwnProperty.call(component.eventBindings, '*') ? component.eventBindings['*'] : undefined;
|
|
|
|
|
|
|
|
const catchAllBinding = component.$$.callbacks && Object.prototype.hasOwnProperty.call(component.$$.callbacks, '*') ? component.$$.callbacks['*'] : undefined;
|
|
|
|
|
|
|
|
|
|
|
|
if (callbacks) {
|
|
|
|
if (callbacks) {
|
|
|
|
// TODO are there situations where events could be dispatched
|
|
|
|
// TODO are there situations where events could be dispatched
|
|
|
|
// in a server (non-DOM) environment?
|
|
|
|
// in a server (non-DOM) environment?
|
|
|
|
@ -47,8 +49,8 @@ export function createEventDispatcher<
|
|
|
|
|
|
|
|
|
|
|
|
if (eventBinding) {
|
|
|
|
if (eventBinding) {
|
|
|
|
// in a server (non-DOM) environment?
|
|
|
|
// in a server (non-DOM) environment?
|
|
|
|
const event = custom_event(type, detail);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
const event = custom_event(type, detail);
|
|
|
|
eventBinding[0].call(component, event, eventBinding[1].data);
|
|
|
|
eventBinding[0].call(component, event, eventBinding[1].data);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.warn(`A component was instantiated with invalid event:bindings - ${e}`);
|
|
|
|
console.warn(`A component was instantiated with invalid event:bindings - ${e}`);
|
|
|
|
@ -64,6 +66,16 @@ export function createEventDispatcher<
|
|
|
|
console.warn(`A component was instantiated with invalid event:bindings - ${e}`);
|
|
|
|
console.warn(`A component was instantiated with invalid event:bindings - ${e}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (catchAllBinding) {
|
|
|
|
|
|
|
|
// in a server (non-DOM) environment?
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const event = custom_event(type, detail);
|
|
|
|
|
|
|
|
catchAllBinding[0].call(component, event, catchAllBinding[1].data);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.warn(`A component was instantiated with invalid on:* configuration - ${e}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|