diff --git a/packages/reactivity/__tests__/reactiveArray.spec.ts b/packages/reactivity/__tests__/reactiveArray.spec.ts index 0ab458d3..170cb1b3 100644 --- a/packages/reactivity/__tests__/reactiveArray.spec.ts +++ b/packages/reactivity/__tests__/reactiveArray.spec.ts @@ -124,6 +124,8 @@ describe('reactivity/reactive/Array', () => { expect(fn).toHaveBeenCalledTimes(1) observed[-1] = 'x' expect(fn).toHaveBeenCalledTimes(1) + observed[NaN] = 'x' + expect(fn).toHaveBeenCalledTimes(1) }) describe('Array methods w/ refs', () => { diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 7daeaa52..46f1a462 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -87,7 +87,10 @@ export const isPlainObject = (val: unknown): val is object => toTypeString(val) === '[object Object]' 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( 'key,ref,' +