|
|
@ -1037,6 +1037,8 @@ function serialize_inline_component(node, component_name, context) {
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {import('estree').Statement[]} */
|
|
|
|
/** @type {import('estree').Statement[]} */
|
|
|
|
const snippet_declarations = [];
|
|
|
|
const snippet_declarations = [];
|
|
|
|
|
|
|
|
/** @type {import('estree').Property[]} */
|
|
|
|
|
|
|
|
const serialized_slots = [];
|
|
|
|
|
|
|
|
|
|
|
|
// Group children by slot
|
|
|
|
// Group children by slot
|
|
|
|
for (const child of node.fragment.nodes) {
|
|
|
|
for (const child of node.fragment.nodes) {
|
|
|
@ -1050,6 +1052,8 @@ function serialize_inline_component(node, component_name, context) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
push_prop(b.prop('init', child.expression, child.expression));
|
|
|
|
push_prop(b.prop('init', child.expression, child.expression));
|
|
|
|
|
|
|
|
// Back/forward compatibility: allows people to pass snippets when component still uses slots
|
|
|
|
|
|
|
|
serialized_slots.push(b.init(child.expression.name, b.true));
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1071,9 +1075,6 @@ function serialize_inline_component(node, component_name, context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Serialize each slot
|
|
|
|
// Serialize each slot
|
|
|
|
/** @type {import('estree').Property[]} */
|
|
|
|
|
|
|
|
const serialized_slots = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const slot_name of Object.keys(children)) {
|
|
|
|
for (const slot_name of Object.keys(children)) {
|
|
|
|
const body = create_block(node, children[slot_name], context);
|
|
|
|
const body = create_block(node, children[slot_name], context);
|
|
|
|
if (body.length === 0) continue;
|
|
|
|
if (body.length === 0) continue;
|
|
|
@ -1750,7 +1751,7 @@ const template_visitors = {
|
|
|
|
const lets = [];
|
|
|
|
const lets = [];
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {import('estree').Expression} */
|
|
|
|
/** @type {import('estree').Expression} */
|
|
|
|
let expression = b.call('$.default_slot', b.id('$$props'));
|
|
|
|
let slot_name = b.literal('default');
|
|
|
|
|
|
|
|
|
|
|
|
for (const attribute of node.attributes) {
|
|
|
|
for (const attribute of node.attributes) {
|
|
|
|
if (attribute.type === 'SpreadAttribute') {
|
|
|
|
if (attribute.type === 'SpreadAttribute') {
|
|
|
@ -1758,7 +1759,7 @@ const template_visitors = {
|
|
|
|
} else if (attribute.type === 'Attribute') {
|
|
|
|
} else if (attribute.type === 'Attribute') {
|
|
|
|
const value = serialize_attribute_value(attribute.value, context, false, true);
|
|
|
|
const value = serialize_attribute_value(attribute.value, context, false, true);
|
|
|
|
if (attribute.name === 'name') {
|
|
|
|
if (attribute.name === 'name') {
|
|
|
|
expression = b.member(b.member_id('$$props.$$slots'), value, true, true);
|
|
|
|
slot_name = value;
|
|
|
|
} else if (attribute.name !== 'slot') {
|
|
|
|
} else if (attribute.name !== 'slot') {
|
|
|
|
if (attribute.metadata.dynamic) {
|
|
|
|
if (attribute.metadata.dynamic) {
|
|
|
|
props.push(b.get(attribute.name, [b.return(value)]));
|
|
|
|
props.push(b.get(attribute.name, [b.return(value)]));
|
|
|
@ -1782,7 +1783,14 @@ const template_visitors = {
|
|
|
|
node.fragment.nodes.length === 0
|
|
|
|
node.fragment.nodes.length === 0
|
|
|
|
? b.literal(null)
|
|
|
|
? b.literal(null)
|
|
|
|
: b.thunk(b.block(create_block(node, node.fragment.nodes, context)));
|
|
|
|
: b.thunk(b.block(create_block(node, node.fragment.nodes, context)));
|
|
|
|
const slot = b.call('$.slot', b.id('$$payload'), expression, props_expression, fallback);
|
|
|
|
const slot = b.call(
|
|
|
|
|
|
|
|
'$.slot',
|
|
|
|
|
|
|
|
b.id('$$payload'),
|
|
|
|
|
|
|
|
b.id('$$props'),
|
|
|
|
|
|
|
|
slot_name,
|
|
|
|
|
|
|
|
props_expression,
|
|
|
|
|
|
|
|
fallback
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
state.template.push(t_statement(b.stmt(slot)));
|
|
|
|
state.template.push(t_statement(b.stmt(slot)));
|
|
|
|
state.template.push(block_close);
|
|
|
|
state.template.push(block_close);
|
|
|
|