expect(source).toHaveBeenCalledWith(instance)
})
+ test('should not leak `this.proxy` to setup()', () => {
+ const source = jest.fn()
+
+ const Comp = defineComponent({
+ render() {},
+ setup() {
+ watch(source, () => {})
+ }
+ })
+
+ const root = nodeOps.createElement('div')
+ createApp(Comp).mount(root)
+ // should not have any arguments
+ expect(source.mock.calls[0]).toMatchObject([])
+ })
+
// #2728
test('pre watcher callbacks should not track dependencies', async () => {
const a = ref(0)
await nextTick()
expect(spy).toHaveBeenCalledTimes(2)
})
-
+
it('watching sources: ref<any[]>', async () => {
const foo = ref([1])
const spy = jest.fn()
} else if (isReactive(s)) {
return traverse(s)
} else if (isFunction(s)) {
- return callWithErrorHandling(s, instance, ErrorCodes.WATCH_GETTER, [
- instance && (instance.proxy as any)
- ])
+ return callWithErrorHandling(s, instance, ErrorCodes.WATCH_GETTER)
} else {
__DEV__ && warnInvalidSource(s)
}
if (cb) {
// getter with cb
getter = () =>
- callWithErrorHandling(source, instance, ErrorCodes.WATCH_GETTER, [
- instance && (instance.proxy as any)
- ])
+ callWithErrorHandling(source, instance, ErrorCodes.WATCH_GETTER)
} else {
// no cb -> simple effect
getter = () => {
? source.includes('.')
? createPathGetter(publicThis, source)
: () => publicThis[source]
- : source.bind(publicThis)
+ : source.bind(publicThis, publicThis)
let cb
if (isFunction(value)) {
cb = value