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`); 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'] : []); const fragment_dependencies = new Set(this.slots.size ? ['$$scope'] : []);
this.slots.forEach(slot => { this.slots.forEach(slot => {
slot.block.dependencies.forEach(name => { slot.block.dependencies.forEach(name => {

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

Loading…
Cancel
Save