File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
packages/runtime-core/src Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 44 type ComponentOptions ,
55 type ConcreteComponent ,
66 currentInstance ,
7+ getComponentName ,
78 isInSSRComponentSetup ,
89} from './component'
910import { isFunction , isObject } from '@vue/shared'
@@ -121,14 +122,27 @@ export function defineAsyncComponent<
121122 __asyncLoader : load ,
122123
123124 __asyncHydrate ( el , instance , hydrate ) {
125+ let patched = false
124126 const doHydrate = hydrateStrategy
125127 ? ( ) => {
126- const teardown = hydrateStrategy ( hydrate , cb =>
128+ const performHydrate = ( ) => {
129+ // skip hydration if the component has been patched
130+ if ( __DEV__ && patched ) {
131+ warn (
132+ `Skipping lazy hydration for component '${ getComponentName ( resolvedComp ! ) } ': ` +
133+ `it was updated before lazy hydration performed.` ,
134+ )
135+ return
136+ }
137+ hydrate ( )
138+ }
139+ const teardown = hydrateStrategy ( performHydrate , cb =>
127140 forEachElement ( el , cb ) ,
128141 )
129142 if ( teardown ) {
130143 ; ( instance . bum || ( instance . bum = [ ] ) ) . push ( teardown )
131144 }
145+ ; ( instance . u || ( instance . u = [ ] ) ) . push ( ( ) => ( patched = true ) )
132146 }
133147 : hydrate
134148 if ( resolvedComp ) {
You can’t perform that action at this time.
0 commit comments