Skip to content

Commit 6e20219

Browse files
committed
more
1 parent f3847d7 commit 6e20219

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ function is_statement(node) {
6060
/**
6161
* @param {Array<import('estree').Statement | import('estree').Expression>} template
6262
* @param {import('estree').Identifier} out
63+
* @param {import('estree').AssignmentOperator} operator
6364
* @returns {import('estree').Statement[]}
6465
*/
65-
function serialize_template(template, out = b.id('out')) {
66+
function serialize_template(template, out = b.id('$$payload.out'), operator = '+=') {
6667
/** @type {import('estree').TemplateElement[]} */
6768
let quasis = [];
6869

@@ -73,9 +74,7 @@ function serialize_template(template, out = b.id('out')) {
7374
const statements = [];
7475

7576
const flush = () => {
76-
statements.push(
77-
b.stmt(b.assignment('+=', b.member(b.id('$$payload'), out), b.template(quasis, expressions)))
78-
);
77+
statements.push(b.stmt(b.assignment(operator, out, b.template(quasis, expressions))));
7978
quasis = [];
8079
expressions = [];
8180
};
@@ -1524,18 +1523,12 @@ const template_visitors = {
15241523
context.state.template.push(block);
15251524
},
15261525
TitleElement(node, context) {
1527-
const state = context.state;
1528-
1529-
/** @type {import('./types').ComponentServerTransformState} */
1530-
const inner_state = { ...state, init: [], template: [] };
1531-
1532-
process_children(node.fragment.nodes, { ...context, state: inner_state });
1533-
1534-
// Use `=` so that later title changes override earlier ones
1535-
state.init.push(b.stmt(b.assignment('=', b.id('$$payload.title'), b.literal('<title>'))));
1536-
inner_state.template.push(string('</title>'));
15371526
// title is guaranteed to contain only text/expression tag children
1538-
state.init.push(...serialize_template(inner_state.template, b.id('title')));
1527+
const template = [string('<title>')];
1528+
process_children(node.fragment.nodes, { ...context, state: { ...context.state, template } });
1529+
template.push(string('</title>'));
1530+
1531+
context.state.init.push(...serialize_template(template, b.id('$$payload.title'), '='));
15391532
},
15401533
SlotElement(node, context) {
15411534
/** @type {import('estree').Property[]} */

0 commit comments

Comments
 (0)