@@ -61,8 +61,7 @@ import {
61
61
push ,
62
62
current_component_context ,
63
63
pop ,
64
- schedule_task ,
65
- managed_render_effect
64
+ schedule_task
66
65
} from './runtime.js' ;
67
66
import {
68
67
current_hydration_fragment ,
@@ -199,7 +198,7 @@ export function comment(anchor) {
199
198
/**
200
199
* @param {Element | Text } dom
201
200
* @param {boolean } is_fragment
202
- * @param {null | Text | Comment | Element } anchor
201
+ * @param {null | (( Text | Comment | Element) & {$$fragment: undefined | Node[]}) } anchor
203
202
* @returns {void }
204
203
*/
205
204
function close_template ( dom , is_fragment , anchor ) {
@@ -211,14 +210,18 @@ function close_template(dom, is_fragment, anchor) {
211
210
? dom
212
211
: /** @type {import('./types.js').TemplateNode[] } */ ( Array . from ( dom . childNodes ) )
213
212
: dom ;
214
- if ( anchor !== null && current_hydration_fragment === null ) {
215
- insert ( current , null , anchor ) ;
213
+ if ( anchor !== null ) {
214
+ if ( current_hydration_fragment === null ) {
215
+ insert ( current , null , anchor ) ;
216
+ } else {
217
+ cleanup_hyration_node ( anchor ) ;
218
+ }
216
219
}
217
220
block . d = current ;
218
221
}
219
222
220
223
/**
221
- * @param {null | Text | Comment | Element } anchor
224
+ * @param {null | (( Text | Comment | Element) & {$$fragment: undefined | Node[]}) } anchor
222
225
* @param {Element | Text } dom
223
226
* @returns {void }
224
227
*/
@@ -227,7 +230,7 @@ export function close(anchor, dom) {
227
230
}
228
231
229
232
/**
230
- * @param {null | Text | Comment | Element } anchor
233
+ * @param {null | (( Text | Comment | Element) & {$$fragment: undefined | Node[]}) } anchor
231
234
* @param {Element | Text } dom
232
235
* @returns {void }
233
236
*/
@@ -1341,6 +1344,20 @@ export function slot(anchor_node, slot_fn, slot_props, fallback_fn) {
1341
1344
} else {
1342
1345
slot_fn ( anchor_node , slot_props ) ;
1343
1346
}
1347
+ cleanup_hyration_node ( anchor_node ) ;
1348
+ }
1349
+
1350
+ /**
1351
+ *
1352
+ * @param {Element | Comment } node
1353
+ */
1354
+ function cleanup_hyration_node ( node ) {
1355
+ // Let's ensure we don't leak the hydration fragment
1356
+ // @ts -expect-error internal field
1357
+ if ( node . $$fragment ) {
1358
+ // @ts -expect-error internal field
1359
+ node . $$fragment = undefined ;
1360
+ }
1344
1361
}
1345
1362
1346
1363
/**
@@ -1472,6 +1489,7 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
1472
1489
destroy_signal ( alternate_effect ) ;
1473
1490
} ) ;
1474
1491
block . e = if_effect ;
1492
+ cleanup_hyration_node ( anchor_node ) ;
1475
1493
}
1476
1494
export { if_block as if } ;
1477
1495
@@ -1615,6 +1633,7 @@ export function element(anchor_node, tag_fn, render_fn, is_svg = false) {
1615
1633
}
1616
1634
destroy_signal ( render_effect_signal ) ;
1617
1635
} ) ;
1636
+ cleanup_hyration_node ( anchor_node ) ;
1618
1637
block . e = element_effect ;
1619
1638
}
1620
1639
@@ -1732,6 +1751,7 @@ export function component(anchor_node, component_fn, render_fn) {
1732
1751
render = render . p ;
1733
1752
}
1734
1753
} ) ;
1754
+ cleanup_hyration_node ( anchor_node ) ;
1735
1755
block . e = component_effect ;
1736
1756
}
1737
1757
@@ -1899,6 +1919,7 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
1899
1919
render = render . p ;
1900
1920
}
1901
1921
} ) ;
1922
+ cleanup_hyration_node ( anchor_node ) ;
1902
1923
block . e = await_effect ;
1903
1924
}
1904
1925
export { await_block as await } ;
@@ -2015,6 +2036,7 @@ export function key(anchor_node, key, render_fn) {
2015
2036
render = render . p ;
2016
2037
}
2017
2038
} ) ;
2039
+ cleanup_hyration_node ( anchor_node ) ;
2018
2040
block . e = key_effect ;
2019
2041
}
2020
2042
@@ -2270,6 +2292,7 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
2270
2292
reconcile_fn ( [ ] , block , anchor_node , is_controlled , render_fn , flags , false , keys ) ;
2271
2293
destroy_signal ( /** @type {import('./types.js').EffectSignal } */ ( render ) ) ;
2272
2294
} ) ;
2295
+ cleanup_hyration_node ( anchor_node ) ;
2273
2296
block . e = each ;
2274
2297
}
2275
2298
0 commit comments