@@ -91,6 +91,7 @@ export function svg_template_with_script(svg, return_fragment) {
91
91
function open_template ( is_fragment , use_clone_node , anchor , template_element_fn ) {
92
92
if ( hydrating ) {
93
93
if ( anchor !== null ) {
94
+ // TODO why is this sometimes null and sometimes not? needs clear documentation
94
95
hydrate_block_anchor ( anchor ) ;
95
96
}
96
97
@@ -171,28 +172,28 @@ export function comment(anchor) {
171
172
/**
172
173
* Assign the created (or in hydration mode, traversed) dom elements to the current block
173
174
* and insert the elements into the dom (in client mode).
174
- * @param {Element | Text } dom
175
+ * @param {import('#client').Dom } dom
175
176
* @param {boolean } is_fragment
176
177
* @param {null | Text | Comment | Element } anchor
177
178
* @returns {import('#client').Dom }
178
179
*/
179
180
function close_template ( dom , is_fragment , anchor ) {
180
- /** @type { import('#client').Dom } */
181
- var current = is_fragment
182
- ? hydrating
183
- ? // if hydrating, `dom` is already an array of nodes
184
- dom
185
- : // otherwise we need to create an array to store it on the current effect
186
- /** @type { import('#client').TemplateNode[] } */ ( Array . from ( dom . childNodes ) )
187
- : dom ;
188
-
189
- if ( ! hydrating && anchor !== null ) {
190
- insert ( current , anchor ) ;
181
+ if ( ! hydrating ) {
182
+ if ( is_fragment ) {
183
+ // if hydrating, `dom` is already an array of nodes, but if not then
184
+ // we need to create an array to store it on the current effect
185
+ dom = /** @type { import('#client').Dom } */ ( Array . from ( /** @type { Node } */ ( dom ) . childNodes ) ) ;
186
+ }
187
+
188
+ if ( anchor !== null ) {
189
+ // TODO as with `open_template — why is this sometimes null and sometimes not?
190
+ insert ( dom , anchor ) ;
191
+ }
191
192
}
192
193
193
- /** @type {import('#client').Effect } */ ( current_effect ) . dom = current ;
194
+ /** @type {import('#client').Effect } */ ( current_effect ) . dom = dom ;
194
195
195
- return current ;
196
+ return dom ;
196
197
}
197
198
198
199
/**
0 commit comments