@ -5,9 +5,7 @@ import { hydrate_node, hydrating } from '../dom/hydration.js';
import { block , branch , destroy _effect } from '../reactivity/effects.js' ;
import { block , branch , destroy _effect } from '../reactivity/effects.js' ;
import { set , source } from '../reactivity/sources.js' ;
import { set , source } from '../reactivity/sources.js' ;
import { set _should _intro } from '../render.js' ;
import { set _should _intro } from '../render.js' ;
import { get } from '../runtime.js' ;
import { active _effect , get } from '../runtime.js' ;
import { assign _nodes } from '../dom/template.js' ;
import { create _comment } from '../dom/operations.js' ;
/ * *
/ * *
* @ template { ( anchor : Comment , props : any ) => any } Component
* @ template { ( anchor : Comment , props : any ) => any } Component
@ -29,19 +27,6 @@ export function hmr(fn) {
let ran = false ;
let ran = false ;
// Surround the wrapped effects with comments and assign the nodes
// on the wrapping effects so the parent can properly do DOM operations.
let start = create _comment ( ) ;
let end = create _comment ( ) ;
// During hydration, inserting the start comment before the anchor could
// corrupt the DOM tree that the hydration walker is navigating (e.g. when
// a component is inside a CSS props wrapper gh-issue#17972). We defer the insertion until
// after the component has hydrated.
if ( ! hydrating ) {
anchor . before ( start ) ;
}
block ( ( ) => {
block ( ( ) => {
if ( component === ( component = get ( current ) ) ) {
if ( component === ( component = get ( current ) ) ) {
return ;
return ;
@ -68,21 +53,19 @@ export function hmr(fn) {
if ( ran ) set _should _intro ( true ) ;
if ( ran ) set _should _intro ( true ) ;
} ) ;
} ) ;
// Forward the nodes from the inner effect to the outer active effect which would
// get them if the HMR wrapper wasn't there. Do this inside the block not outside
// so that HMR updates to the component will also update the nodes on the active effect.
/** @type {Effect} */ ( active _effect ) . nodes = effect . nodes ;
} , EFFECT _TRANSPARENT ) ;
} , EFFECT _TRANSPARENT ) ;
ran = true ;
ran = true ;
if ( hydrating ) {
if ( hydrating ) {
// Insert start comment now that hydration is done, so it doesn't
// corrupt the hydration walk
anchor . before ( start ) ;
anchor = hydrate _node ;
anchor = hydrate _node ;
}
}
anchor . before ( end ) ;
assign _nodes ( start , end ) ;
return instance ;
return instance ;
}
}