pull/12335/head
Rich Harris 2 years ago
parent 65f8675b41
commit 65d2053aa3

@ -1610,6 +1610,10 @@ export const template_visitors = {
context.visit(node, state);
}
if (is_anchored) {
body.push(b.stmt(b.call('$.next')));
}
/**
* @param {import('estree').Identifier} template_name
* @param {import('estree').Expression[]} args
@ -1668,11 +1672,7 @@ export const template_visitors = {
state
});
body.push(
b.var(id, b.call('$.text', is_anchored && b.true)),
...state.before_init,
...state.init
);
body.push(b.var(id, b.call('$.text')), ...state.before_init, ...state.init);
close = b.stmt(b.call('$.append', b.id('$$anchor'), id));
} else {
if (is_standalone) {

@ -1143,9 +1143,9 @@ const template_visitors = {
process_children(trimmed, { ...context, state });
if (is_anchored) {
state.template.push(b.literal('<!---->'));
}
// if (is_anchored) {
// state.template.push(b.literal('<!---->'));
// }
return b.block([...state.init, ...serialize_template(state.template)]);
},

@ -284,15 +284,10 @@ export function clean_nodes(
(attribute) => attribute.type === 'Attribute' && attribute.name.startsWith('--')
)));
// if a component or snippet only contains text, we need to add an anchor comment
// if a component or snippet starts with text, we need to add an anchor comment
// so that its text node doesn't get fused with its surroundings
const is_dynamic_text =
trimmed.every((node) => node.type === 'Text' || node.type === 'ExpressionTag') &&
trimmed.some((node) => node.type === 'ExpressionTag');
const is_text = trimmed.length === 1 && first.type === 'Text';
const is_anchored = (is_dynamic_text || is_text) && parent.type === 'Fragment';
const is_anchored =
parent.type === 'Fragment' && (first.type === 'Text' || first.type === 'ExpressionTag');
return { hoisted, trimmed, is_standalone: false, is_anchored };
}

@ -232,9 +232,9 @@ export function text(anchored) {
set_hydrate_node(node);
}
if (anchored) {
hydrate_next();
}
// if (anchored) {
// hydrate_next();
// }
assign_nodes(node, node);
return node;

Loading…
Cancel
Save