fix(runtime-core): should pause tracking when initializing legacy options (#2524)
fix #2521
This commit is contained in:
@@ -232,4 +232,47 @@ describe('renderer: component', () => {
|
||||
await nextTick()
|
||||
expect(serializeInner(root)).toBe(`<div>1</div><div>1</div>`)
|
||||
})
|
||||
|
||||
// #2521
|
||||
test('should pause tracking deps when initializing legacy options', async () => {
|
||||
let childInstance = null as any
|
||||
const Child = {
|
||||
props: ['foo'],
|
||||
data() {
|
||||
return {
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
foo: {
|
||||
immediate: true,
|
||||
handler() {
|
||||
;(this as any).count
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
childInstance = this as any
|
||||
childInstance.count
|
||||
},
|
||||
render() {
|
||||
return h('h1', (this as any).count)
|
||||
}
|
||||
}
|
||||
|
||||
const App = {
|
||||
setup() {
|
||||
return () => h(Child)
|
||||
},
|
||||
updated: jest.fn()
|
||||
}
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(App), root)
|
||||
expect(App.updated).toHaveBeenCalledTimes(0)
|
||||
|
||||
childInstance.count++
|
||||
await nextTick()
|
||||
expect(App.updated).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user