Errors from slots bubble to the provider component

pull/6585/head
rster20002 5 years ago
parent e71ca48735
commit 81e8ff5cfb

@ -192,6 +192,10 @@ export default class InlineComponentWrapper extends Wrapper {
component_opts.properties.push(p`$$inline: true`);
}
if (block.type === "slot") {
component_opts.properties.push(p`$$in_slot: true`);
}
const fragment_dependencies = new Set(this.slots.size ? ['$$scope'] : []);
this.slots.forEach(slot => {
slot.block.dependencies.forEach(name => {

@ -116,23 +116,25 @@ export function attach_error_handler(that: any, component, fn) {
};
}
export function handle_error(component, e) {
if (component.$$.on_error.length === 0) {
export function handle_error(component, e, skip = false) {
if (component.$$.on_error.length === 0 || skip) {
bubble_error(component, e);
}
component.$$.on_error.forEach(handler => {
try {
handler(e);
} catch (e) {
bubble_error(component, e);
}
});
if (!skip) {
component.$$.on_error.forEach(handler => {
try {
handler(e);
} catch (e) {
bubble_error(component, e);
}
});
}
}
function bubble_error(component, e) {
if (component.$$.parent_component) {
handle_error(component.$$.parent_component, e);
handle_error(component.$$.parent_component, e, component.$$.in_slot);
} else {
throw e;
}
@ -166,6 +168,7 @@ export function init(component, options, instance, create_fragment, not_equal, p
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root,
in_slot: options.$$in_slot || false,
parent_component
};

Loading…
Cancel
Save