fix(runtime-core): should disable tracking inside directive lifecycle hooks (#3699)
This commit is contained in:
@@ -367,4 +367,32 @@ describe('directives', () => {
|
||||
expect(d1.mounted).toHaveBeenCalled()
|
||||
expect(d2.mounted).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('should disable tracking inside directive lifecycle hooks', async () => {
|
||||
const count = ref(0)
|
||||
const text = ref('')
|
||||
const beforeUpdate = jest.fn(() => count.value++)
|
||||
|
||||
const App = {
|
||||
render() {
|
||||
return withDirectives(h('p', text.value), [
|
||||
[
|
||||
{
|
||||
beforeUpdate
|
||||
}
|
||||
]
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
render(h(App), root)
|
||||
expect(beforeUpdate).toHaveBeenCalledTimes(0)
|
||||
expect(count.value).toBe(0)
|
||||
|
||||
text.value = 'foo'
|
||||
await nextTick()
|
||||
expect(beforeUpdate).toHaveBeenCalledTimes(1)
|
||||
expect(count.value).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user