Просмотр исходного кода

fix(ssr): ensure behavior consistency between prod/dev when mounting SSR app to empty containers

close #4034
Evan You 4 лет назад
Родитель
Сommit
33708e8bf4
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      packages/runtime-core/src/hydration.ts

+ 7 - 5
packages/runtime-core/src/hydration.ts

@@ -57,12 +57,14 @@ export function createHydrationFunctions(
   } = rendererInternals
   } = rendererInternals
 
 
   const hydrate: RootHydrateFunction = (vnode, container) => {
   const hydrate: RootHydrateFunction = (vnode, container) => {
-    if (__DEV__ && !container.hasChildNodes()) {
-      warn(
-        `Attempting to hydrate existing markup but container is empty. ` +
-          `Performing full mount instead.`
-      )
+    if (!container.hasChildNodes()) {
+      __DEV__ &&
+        warn(
+          `Attempting to hydrate existing markup but container is empty. ` +
+            `Performing full mount instead.`
+        )
       patch(null, vnode, container)
       patch(null, vnode, container)
+      flushPostFlushCbs()
       return
       return
     }
     }
     hasMismatch = false
     hasMismatch = false