fix(reactivity): use correct thisArg for collection method callbacks (#1132)

This commit is contained in:
龙腾道
2020-05-07 01:41:34 +08:00
committed by GitHub
parent 4df180607d
commit e08f6f0ede
2 changed files with 16 additions and 2 deletions

View File

@@ -412,5 +412,19 @@ describe('reactivity/collections', () => {
`Reactive Set contains both the raw and reactive`
).toHaveBeenWarned()
})
it('thisArg', () => {
const raw = new Set([ 'value' ])
const proxy = reactive(raw)
const thisArg = {}
let count = 0
proxy.forEach(function (this :{}, value, _, set) {
++count
expect(this).toBe(thisArg)
expect(value).toBe('value')
expect(set).toBe(proxy)
}, thisArg)
expect(count).toBe(1)
})
})
})