@@ -33,23 +33,23 @@ const INVALID_ATTR_NAME_CHAR_REGEX =
33
33
* @returns {void }
34
34
*/
35
35
export function element ( payload , tag , attributes_fn = noop , children_fn = noop ) {
36
- payload . out += '<!---->' ;
36
+ payload . out . push ( '<!---->' ) ;
37
37
38
38
if ( tag ) {
39
- payload . out += `<${ tag } ` ;
39
+ payload . out . push ( `<${ tag } ` ) ;
40
40
attributes_fn ( ) ;
41
- payload . out += `>` ;
41
+ payload . out . push ( `>` ) ;
42
42
43
43
if ( ! is_void ( tag ) ) {
44
44
children_fn ( ) ;
45
45
if ( ! is_raw_text_element ( tag ) ) {
46
- payload . out += EMPTY_COMMENT ;
46
+ payload . out . push ( EMPTY_COMMENT ) ;
47
47
}
48
- payload . out += `</${ tag } >` ;
48
+ payload . out . push ( `</${ tag } >` ) ;
49
49
}
50
50
}
51
51
52
- payload . out += '<!---->' ;
52
+ payload . out . push ( '<!---->' ) ;
53
53
}
54
54
55
55
/**
@@ -72,7 +72,7 @@ export function render(component, options = {}) {
72
72
73
73
const prev_on_destroy = on_destroy ;
74
74
on_destroy = [ ] ;
75
- payload . out += BLOCK_OPEN ;
75
+ payload . out . push ( BLOCK_OPEN ) ;
76
76
77
77
let reset_reset_element ;
78
78
@@ -97,20 +97,22 @@ export function render(component, options = {}) {
97
97
reset_reset_element ( ) ;
98
98
}
99
99
100
- payload . out += BLOCK_CLOSE ;
100
+ payload . out . push ( BLOCK_CLOSE ) ;
101
101
for ( const cleanup of on_destroy ) cleanup ( ) ;
102
102
on_destroy = prev_on_destroy ;
103
103
104
- let head = payload . head . out + payload . head . title ;
104
+ let head = payload . head . out . join ( '' ) + payload . head . title ;
105
105
106
106
for ( const { hash, code } of payload . css ) {
107
107
head += `<style id="${ hash } ">${ code } </style>` ;
108
108
}
109
109
110
+ const body = payload . out . join ( '' ) ;
111
+
110
112
return {
111
113
head,
112
- html : payload . out ,
113
- body : payload . out
114
+ html : body ,
115
+ body : body
114
116
} ;
115
117
} finally {
116
118
abort ( ) ;
@@ -124,9 +126,9 @@ export function render(component, options = {}) {
124
126
*/
125
127
export function head ( payload , fn ) {
126
128
const head_payload = payload . head ;
127
- head_payload . out += BLOCK_OPEN ;
129
+ head_payload . out . push ( BLOCK_OPEN ) ;
128
130
fn ( head_payload ) ;
129
- head_payload . out += BLOCK_CLOSE ;
131
+ head_payload . out . push ( BLOCK_CLOSE ) ;
130
132
}
131
133
132
134
/**
@@ -141,21 +143,21 @@ export function css_props(payload, is_html, props, component, dynamic = false) {
141
143
const styles = style_object_to_string ( props ) ;
142
144
143
145
if ( is_html ) {
144
- payload . out += `<svelte-css-wrapper style="display: contents; ${ styles } ">` ;
146
+ payload . out . push ( `<svelte-css-wrapper style="display: contents; ${ styles } ">` ) ;
145
147
} else {
146
- payload . out += `<g style="${ styles } ">` ;
148
+ payload . out . push ( `<g style="${ styles } ">` ) ;
147
149
}
148
150
149
151
if ( dynamic ) {
150
- payload . out += '<!---->' ;
152
+ payload . out . push ( '<!---->' ) ;
151
153
}
152
154
153
155
component ( ) ;
154
156
155
157
if ( is_html ) {
156
- payload . out += `<!----></svelte-css-wrapper>` ;
158
+ payload . out . push ( `<!----></svelte-css-wrapper>` ) ;
157
159
} else {
158
- payload . out += `<!----></g>` ;
160
+ payload . out . push ( `<!----></g>` ) ;
159
161
}
160
162
}
161
163
@@ -440,13 +442,13 @@ export function bind_props(props_parent, props_now) {
440
442
*/
441
443
function await_block ( payload , promise , pending_fn , then_fn ) {
442
444
if ( is_promise ( promise ) ) {
443
- payload . out += BLOCK_OPEN ;
445
+ payload . out . push ( BLOCK_OPEN ) ;
444
446
promise . then ( null , noop ) ;
445
447
if ( pending_fn !== null ) {
446
448
pending_fn ( ) ;
447
449
}
448
450
} else if ( then_fn !== null ) {
449
- payload . out += BLOCK_OPEN_ELSE ;
451
+ payload . out . push ( BLOCK_OPEN_ELSE ) ;
450
452
then_fn ( promise ) ;
451
453
}
452
454
}
@@ -493,7 +495,7 @@ export function once(get_value) {
493
495
*/
494
496
export function props_id ( payload ) {
495
497
const uid = payload . uid ( ) ;
496
- payload . out += '<!--#' + uid + '-->' ;
498
+ payload . out . push ( '<!--#' + uid + '-->' ) ;
497
499
return uid ;
498
500
}
499
501
@@ -562,10 +564,13 @@ export function valueless_option(payload, children) {
562
564
563
565
children ( ) ;
564
566
565
- var body = payload . out . slice ( i ) ;
567
+ var body = payload . out . slice ( i ) . join ( '' ) ;
566
568
567
569
if ( body . replace ( / < ! - - - - > / g, '' ) === payload . select_value ) {
568
570
// replace '>' with ' selected>' (closing tag will be added later)
569
- payload . out = payload . out . slice ( 0 , i - 1 ) + ' selected>' + body ;
571
+ var last_item = payload . out [ i - 1 ] ;
572
+ payload . out [ i - 1 ] = last_item . slice ( 0 , - 1 ) + ' selected>' ;
573
+ // Remove the old items after position i and add the body as a single item
574
+ payload . out . splice ( i , payload . out . length - i , body ) ;
570
575
}
571
576
}
0 commit comments