fix(reactivity): add NaN prop on Array should not trigger length dependency. (#1998)

This commit is contained in:
Hefty 2020-09-15 08:40:09 +08:00 committed by GitHub
parent 124c385baf
commit 0d4910a211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -124,6 +124,8 @@ describe('reactivity/reactive/Array', () => {
expect(fn).toHaveBeenCalledTimes(1) expect(fn).toHaveBeenCalledTimes(1)
observed[-1] = 'x' observed[-1] = 'x'
expect(fn).toHaveBeenCalledTimes(1) expect(fn).toHaveBeenCalledTimes(1)
observed[NaN] = 'x'
expect(fn).toHaveBeenCalledTimes(1)
}) })
describe('Array methods w/ refs', () => { describe('Array methods w/ refs', () => {

View File

@ -87,7 +87,10 @@ export const isPlainObject = (val: unknown): val is object =>
toTypeString(val) === '[object Object]' toTypeString(val) === '[object Object]'
export const isIntegerKey = (key: unknown) => export const isIntegerKey = (key: unknown) =>
isString(key) && key[0] !== '-' && '' + parseInt(key, 10) === key isString(key) &&
key !== 'NaN' &&
key[0] !== '-' &&
'' + parseInt(key, 10) === key
export const isReservedProp = /*#__PURE__*/ makeMap( export const isReservedProp = /*#__PURE__*/ makeMap(
'key,ref,' + 'key,ref,' +