File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed
packages/svelte/src/internal/client/dom Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -115,25 +115,23 @@ export function open_frag(template_element_fn, use_clone_node = true) {
115
115
return open_template ( true , use_clone_node , template_element_fn ) ;
116
116
}
117
117
118
- const space_template = template ( ' ' , false ) ;
119
118
const comment_template = template ( '<!>' , true ) ;
120
119
121
120
/**
122
- * @param {Text | Comment | Element | null } anchor
121
+ * @param {Text | Comment | Element } anchor
123
122
*/
124
123
/*#__NO_SIDE_EFFECTS__*/
125
124
export function space_frag ( anchor ) {
126
- /** @type {Node | null } */
127
- var node = /** @type {any } */ ( open ( space_template ) ) ;
128
- // if an {expression} is empty during SSR, there might be no
129
- // text node to hydrate (or an anchor comment is falsely detected instead)
130
- // — we must therefore create one
131
- if ( hydrating && node ?. nodeType !== 3 ) {
132
- node = empty ( ) ;
133
- // @ts -ignore in this case the anchor should always be a comment,
134
- // if not something more fundamental is wrong and throwing here is better to bail out early
135
- anchor . before ( node ) ;
125
+ if ( ! hydrating ) return empty ( ) ;
126
+
127
+ var node = hydrate_nodes [ 0 ] ;
128
+
129
+ if ( ! node ) {
130
+ // if an {expression} is empty during SSR, `hydrate_nodes` will be empty.
131
+ // we need to insert an empty text node
132
+ anchor . before ( ( node = empty ( ) ) ) ;
136
133
}
134
+
137
135
return node ;
138
136
}
139
137
You can’t perform that action at this time.
0 commit comments