Skip to content

Commit bcc11ce

Browse files
committed
tweak
1 parent ab5f15c commit bcc11ce

File tree

2 files changed

+7
-6
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client

2 files changed

+7
-6
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ function build_locations(locations) {
4848
/**
4949
* @param {ComponentClientTransformState} state
5050
* @param {Namespace} namespace
51-
* @param {Identifier} template_name
5251
* @param {number} [flags]
5352
*/
54-
export function transform_template(state, namespace, template_name, flags) {
53+
export function transform_template(state, namespace, flags) {
5554
const expression =
5655
state.options.templatingMode === 'functional'
5756
? template_to_functions(state.template.nodes)
@@ -64,13 +63,13 @@ export function transform_template(state, namespace, template_name, flags) {
6463
);
6564

6665
if (dev) {
67-
call = b.call(
66+
return b.call(
6867
'$.add_locations',
6968
call,
7069
b.member(b.id(state.analysis.name), '$.FILENAME', true),
7170
build_locations(state.locations)
7271
);
7372
}
7473

75-
state.hoisted.push(b.var(template_name, call));
74+
return call;
7675
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export function Fragment(node, context) {
9696

9797
let flags = state.template.needs_import_node ? TEMPLATE_USE_IMPORT_NODE : undefined;
9898

99-
transform_template(state, namespace, template_name, flags);
99+
const template = transform_template(state, namespace, flags);
100+
state.hoisted.push(b.var(template_name, template));
100101

101102
body.push(b.var(id, b.call(template_name)));
102103
close = b.stmt(b.call('$.append', b.id('$$anchor'), id));
@@ -144,7 +145,8 @@ export function Fragment(node, context) {
144145
// special case — we can use `$.comment` instead of creating a unique template
145146
body.push(b.var(id, b.call('$.comment')));
146147
} else {
147-
transform_template(state, namespace, template_name, flags);
148+
const template = transform_template(state, namespace, flags);
149+
state.hoisted.push(b.var(template_name, template));
148150

149151
body.push(b.var(id, b.call(template_name)));
150152
}

0 commit comments

Comments
 (0)