File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
packages/svelte/src/internal/client/dom/blocks Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -62,20 +62,25 @@ export function head(render_fn) {
62
62
check_end ( ) ;
63
63
} catch ( error ) {
64
64
// Remount only this svelte:head
65
- if ( was_hydrating && head_anchor && error === HYDRATION_ERROR ) {
65
+ if ( was_hydrating && head_anchor != null ) {
66
+ hydration_mismatch ( ) ;
66
67
// Here head_anchor is the node next after HYDRATION_START
67
68
/** @type {Node | null } */
68
- let node = head_anchor . previousSibling ;
69
+ var node = head_anchor . previousSibling ;
69
70
// Remove nodes that failed to hydrate
71
+ var depth = 0 ;
70
72
while ( node !== null ) {
71
- const removed = node ;
73
+ var prev = /** @type { TemplateNode } */ ( node ) ;
72
74
node = get_next_sibling ( node ) ;
73
- document . head . removeChild ( removed ) ;
74
- if (
75
- removed . nodeType === COMMENT_NODE &&
76
- /** @type {Comment } */ ( removed ) . data === HYDRATION_END
77
- ) {
78
- break ;
75
+ prev . remove ( ) ;
76
+ if ( prev . nodeType === COMMENT_NODE ) {
77
+ var data = /** @type {Comment } */ ( prev ) . data ;
78
+ if ( data === HYDRATION_END ) {
79
+ depth -= 1 ;
80
+ if ( depth === 0 ) break ;
81
+ } else if ( data === HYDRATION_START ) {
82
+ depth += 1 ;
83
+ }
79
84
}
80
85
}
81
86
// Setup hydration for the next svelte:head
You can’t perform that action at this time.
0 commit comments