@@ -60,9 +60,10 @@ function is_statement(node) {
60
60
/**
61
61
* @param {Array<import('estree').Statement | import('estree').Expression> } template
62
62
* @param {import('estree').Identifier } out
63
+ * @param {import('estree').AssignmentOperator } operator
63
64
* @returns {import('estree').Statement[] }
64
65
*/
65
- function serialize_template ( template , out = b . id ( 'out' ) ) {
66
+ function serialize_template ( template , out = b . id ( '$$payload. out' ) , operator = '+=' ) {
66
67
/** @type {import('estree').TemplateElement[] } */
67
68
let quasis = [ ] ;
68
69
@@ -73,9 +74,7 @@ function serialize_template(template, out = b.id('out')) {
73
74
const statements = [ ] ;
74
75
75
76
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 ) ) ) ) ;
79
78
quasis = [ ] ;
80
79
expressions = [ ] ;
81
80
} ;
@@ -1524,18 +1523,12 @@ const template_visitors = {
1524
1523
context . state . template . push ( block ) ;
1525
1524
} ,
1526
1525
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>' ) ) ;
1537
1526
// 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' ) , '=' ) ) ;
1539
1532
} ,
1540
1533
SlotElement ( node , context ) {
1541
1534
/** @type {import('estree').Property[] } */
0 commit comments