]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: adjust custom element hmr, fix tests
authorEvan You <yyx990803@gmail.com>
Fri, 23 Jul 2021 03:18:15 +0000 (23:18 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 23 Jul 2021 03:18:15 +0000 (23:18 -0400)
packages/runtime-core/src/hmr.ts

index 45f25ba513773fb9b8cefac772b164507b47db97..a7ccbe9c2dce40b53edc2c710db261cd300c69bc 100644 (file)
@@ -7,7 +7,7 @@ import {
   ClassComponent,
   isClassComponent
 } from './component'
-import { nextTick, queueJob } from './scheduler'
+import { queueJob, queuePostFlushCb } from './scheduler'
 import { extend } from '@vue/shared'
 import { warn } from './warning'
 
@@ -124,7 +124,7 @@ function reload(id: string, newComp: ComponentOptions | ClassComponent) {
     // on patch.
     hmrDirtyComponents.add(component)
     // 3. Make sure to unmark the component after the reload.
-    nextTick(() => {
+    queuePostFlushCb(() => {
       hmrDirtyComponents.delete(component)
     })
   }
@@ -135,7 +135,9 @@ function reload(id: string, newComp: ComponentOptions | ClassComponent) {
 
     if (instance.ceReload) {
       // custom element
+      hmrDirtyComponents.add(component)
       instance.ceReload()
+      hmrDirtyComponents.delete(component)
     } else if (instance.parent) {
       // 4. Force the parent instance to re-render. This will cause all updated
       // components to be unmounted and re-mounted. Queue the update so that we