parent
d9ad45ad6c
commit
0e5a3c47a7
@ -128,6 +128,21 @@ describe('reactivity/reactive/Array', () => {
|
|||||||
expect(fn).toHaveBeenCalledTimes(1)
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #2427
|
||||||
|
test('track length on for ... in iteration', () => {
|
||||||
|
const array = reactive([1])
|
||||||
|
let length = ''
|
||||||
|
effect(() => {
|
||||||
|
length = ''
|
||||||
|
for (const key in array) {
|
||||||
|
length += key
|
||||||
|
}
|
||||||
|
})
|
||||||
|
expect(length).toBe('0')
|
||||||
|
array.push(1)
|
||||||
|
expect(length).toBe('01')
|
||||||
|
})
|
||||||
|
|
||||||
describe('Array methods w/ refs', () => {
|
describe('Array methods w/ refs', () => {
|
||||||
let original: any[]
|
let original: any[]
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -179,7 +179,7 @@ function has(target: object, key: string | symbol): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ownKeys(target: object): (string | number | symbol)[] {
|
function ownKeys(target: object): (string | number | symbol)[] {
|
||||||
track(target, TrackOpTypes.ITERATE, ITERATE_KEY)
|
track(target, TrackOpTypes.ITERATE, isArray(target) ? 'length' : ITERATE_KEY)
|
||||||
return Reflect.ownKeys(target)
|
return Reflect.ownKeys(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user