From 231dafd55a3003601e7746bc0d4177aacbf00fc6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 22 Jul 2021 23:18:15 -0400 Subject: [PATCH] refactor: adjust custom element hmr, fix tests --- packages/runtime-core/src/hmr.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/hmr.ts b/packages/runtime-core/src/hmr.ts index 45f25ba5..a7ccbe9c 100644 --- a/packages/runtime-core/src/hmr.ts +++ b/packages/runtime-core/src/hmr.ts @@ -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