Skip to content

Commit c861477

Browse files
committed
another
1 parent ae9073c commit c861477

File tree

1 file changed

+21
-15
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors

1 file changed

+21
-15
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -847,18 +847,30 @@ function serialize_inline_component(node, component_name, context) {
847847
/** @type {import('estree').Property[]} */
848848
const serialized_slots = [];
849849
for (const slot_name of Object.keys(children)) {
850-
const body = create_block(
851-
node,
852-
node.fragment,
853-
`${node.name}_${slot_name}`,
854-
children[slot_name],
855-
context
850+
const block = /** @type {import('estree').BlockStatement} */ (
851+
context.visit(
852+
{
853+
...node.fragment,
854+
// @ts-expect-error
855+
nodes: children[slot_name]
856+
},
857+
{
858+
...context.state,
859+
scope:
860+
context.state.scopes.get(slot_name === 'default' ? children[slot_name][0] : node) ??
861+
context.state.scope
862+
}
863+
)
856864
);
857-
if (body.length === 0) continue;
865+
866+
if (block.body.length === 0) continue;
858867

859868
const slot_fn = b.arrow(
860869
[b.id('$$anchor'), b.id('$$slotProps')],
861-
b.block([...(slot_name === 'default' && !slot_scope_applies_to_itself ? lets : []), ...body])
870+
b.block([
871+
...(slot_name === 'default' && !slot_scope_applies_to_itself ? lets : []),
872+
...block.body
873+
])
862874
);
863875

864876
if (slot_name === 'default' && !has_children_prop) {
@@ -3032,13 +3044,7 @@ export const template_visitors = {
30323044

30333045
context.state.init.push(...lets);
30343046
context.state.init.push(
3035-
...create_block(
3036-
node,
3037-
node.fragment,
3038-
'slot_template',
3039-
/** @type {import('#compiler').SvelteNode[]} */ (node.fragment.nodes),
3040-
context
3041-
)
3047+
.../** @type {import('estree').BlockStatement} */ (context.visit(node.fragment)).body
30423048
);
30433049
},
30443050
SlotElement(node, context) {

0 commit comments

Comments
 (0)