diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js index e9d58e5b47..e6bb3c067e 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/component.js @@ -64,7 +64,7 @@ export function visit_component(node, context) { // If the component has a slot attribute — `` — // then `let:` directives apply to other attributes, instead of just the // top-level contents of the component. Yes, this is very weird. - const default_state = !!determine_slot(node) + const default_state = determine_slot(node) ? context.state : { ...context.state, scope: node.metadata.scopes.default }; diff --git a/packages/svelte/src/compiler/phases/scope.js b/packages/svelte/src/compiler/phases/scope.js index 17957292a5..633f326080 100644 --- a/packages/svelte/src/compiler/phases/scope.js +++ b/packages/svelte/src/compiler/phases/scope.js @@ -303,7 +303,7 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) { default: context.state.scope.child() }; - const default_state = !!determine_slot(node) + const default_state = determine_slot(node) ? context.state : { scope: node.metadata.scopes.default };