pull/15538/head
Rich Harris 4 months ago
parent ab5f15c324
commit bcc11ceb38

@ -48,10 +48,9 @@ function build_locations(locations) {
/** /**
* @param {ComponentClientTransformState} state * @param {ComponentClientTransformState} state
* @param {Namespace} namespace * @param {Namespace} namespace
* @param {Identifier} template_name
* @param {number} [flags] * @param {number} [flags]
*/ */
export function transform_template(state, namespace, template_name, flags) { export function transform_template(state, namespace, flags) {
const expression = const expression =
state.options.templatingMode === 'functional' state.options.templatingMode === 'functional'
? template_to_functions(state.template.nodes) ? template_to_functions(state.template.nodes)
@ -64,7 +63,7 @@ export function transform_template(state, namespace, template_name, flags) {
); );
if (dev) { if (dev) {
call = b.call( return b.call(
'$.add_locations', '$.add_locations',
call, call,
b.member(b.id(state.analysis.name), '$.FILENAME', true), b.member(b.id(state.analysis.name), '$.FILENAME', true),
@ -72,5 +71,5 @@ export function transform_template(state, namespace, template_name, flags) {
); );
} }
state.hoisted.push(b.var(template_name, call)); return call;
} }

@ -96,7 +96,8 @@ export function Fragment(node, context) {
let flags = state.template.needs_import_node ? TEMPLATE_USE_IMPORT_NODE : undefined; let flags = state.template.needs_import_node ? TEMPLATE_USE_IMPORT_NODE : undefined;
transform_template(state, namespace, template_name, flags); const template = transform_template(state, namespace, flags);
state.hoisted.push(b.var(template_name, template));
body.push(b.var(id, b.call(template_name))); body.push(b.var(id, b.call(template_name)));
close = b.stmt(b.call('$.append', b.id('$$anchor'), id)); close = b.stmt(b.call('$.append', b.id('$$anchor'), id));
@ -144,7 +145,8 @@ export function Fragment(node, context) {
// special case — we can use `$.comment` instead of creating a unique template // special case — we can use `$.comment` instead of creating a unique template
body.push(b.var(id, b.call('$.comment'))); body.push(b.var(id, b.call('$.comment')));
} else { } else {
transform_template(state, namespace, template_name, flags); const template = transform_template(state, namespace, flags);
state.hoisted.push(b.var(template_name, template));
body.push(b.var(id, b.call(template_name))); body.push(b.var(id, b.call(template_name)));
} }

Loading…
Cancel
Save