Skip to content

Commit

Permalink
refactor: adjust custom element hmr, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 23, 2021
1 parent bff4ea7 commit 231dafd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/runtime-core/src/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
})
}
Expand All @@ -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
Expand Down

0 comments on commit 231dafd

Please sign in to comment.