fix(hmr): make hmr working with class components (#2144)
This commit is contained in:
@@ -3,7 +3,9 @@ import {
|
||||
ConcreteComponent,
|
||||
ComponentInternalInstance,
|
||||
ComponentOptions,
|
||||
InternalRenderFunction
|
||||
InternalRenderFunction,
|
||||
ClassComponent,
|
||||
isClassComponent
|
||||
} from './component'
|
||||
import { queueJob, queuePostFlushCb } from './scheduler'
|
||||
import { extend } from '@vue/shared'
|
||||
@@ -83,7 +85,7 @@ function rerender(id: string, newRender?: Function) {
|
||||
})
|
||||
}
|
||||
|
||||
function reload(id: string, newComp: ComponentOptions) {
|
||||
function reload(id: string, newComp: ComponentOptions | ClassComponent) {
|
||||
const record = map.get(id)
|
||||
if (!record) return
|
||||
// Array.from creates a snapshot which avoids the set being mutated during
|
||||
@@ -92,6 +94,7 @@ function reload(id: string, newComp: ComponentOptions) {
|
||||
const comp = instance.type
|
||||
if (!hmrDirtyComponents.has(comp)) {
|
||||
// 1. Update existing comp definition to match new one
|
||||
newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp
|
||||
extend(comp, newComp)
|
||||
for (const key in comp) {
|
||||
if (!(key in newComp)) {
|
||||
|
||||
Reference in New Issue
Block a user