Skip to content

Commit 98fa3c0

Browse files
committed
simplify
1 parent 310f82d commit 98fa3c0

File tree

1 file changed

+16
-25
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/transform-template

1 file changed

+16
-25
lines changed

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

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,34 +53,25 @@ function build_locations(locations) {
5353
* @param {number} [flags]
5454
*/
5555
export function transform_template(state, context, namespace, template_name, flags) {
56-
/**
57-
* @param {Identifier} template_name
58-
* @param {Expression[]} args
59-
*/
60-
const add_template = (template_name, args) => {
61-
let call = b.call(get_template_function(namespace, state), ...args);
62-
if (dev) {
63-
call = b.call(
64-
'$.add_locations',
65-
call,
66-
b.member(b.id(context.state.analysis.name), '$.FILENAME', true),
67-
build_locations(state.locations)
68-
);
69-
}
70-
71-
context.state.hoisted.push(b.var(template_name, call));
72-
};
73-
74-
/** @type {Expression[]} */
75-
const args = [
56+
const expression =
7657
state.options.templatingMode === 'functional'
7758
? template_to_functions(state.template.nodes)
78-
: template_to_string(state.template.nodes)
79-
];
59+
: template_to_string(state.template.nodes);
60+
61+
let call = b.call(
62+
get_template_function(namespace, state),
63+
expression,
64+
flags ? b.literal(flags) : undefined
65+
);
8066

81-
if (flags) {
82-
args.push(b.literal(flags));
67+
if (dev) {
68+
call = b.call(
69+
'$.add_locations',
70+
call,
71+
b.member(b.id(context.state.analysis.name), '$.FILENAME', true),
72+
build_locations(state.locations)
73+
);
8374
}
8475

85-
add_template(template_name, args);
76+
context.state.hoisted.push(b.var(template_name, call));
8677
}

0 commit comments

Comments
 (0)