fix(runtime-core): instanceWatch should pass this.proxy to source as the first argument (#2753)
This commit is contained in:
@@ -15,7 +15,8 @@ import {
|
||||
nodeOps,
|
||||
serializeInner,
|
||||
TestElement,
|
||||
h
|
||||
h,
|
||||
createApp
|
||||
} from '@vue/runtime-test'
|
||||
import {
|
||||
ITERATE_KEY,
|
||||
@@ -857,4 +858,23 @@ describe('api: watch', () => {
|
||||
|
||||
expect(instance!.effects![0].active).toBe(false)
|
||||
})
|
||||
|
||||
test('this.$watch should pass `this.proxy` to watch source as the first argument ', () => {
|
||||
let instance: any
|
||||
const source = jest.fn()
|
||||
|
||||
const Comp = defineComponent({
|
||||
render() {},
|
||||
created(this: any) {
|
||||
instance = this
|
||||
this.$watch(source, function() {})
|
||||
}
|
||||
})
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
createApp(Comp).mount(root)
|
||||
|
||||
expect(instance).toBeDefined()
|
||||
expect(source).toHaveBeenCalledWith(instance)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user