refactor: use Number constructor when coercing array length

This commit is contained in:
Evan You 2022-11-14 16:10:05 +08:00
parent 3427052229
commit efa2ac54d9
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { TrackOpTypes, TriggerOpTypes } from './operations'
import { extend, isArray, isIntegerKey, isMap, toNumber } from '@vue/shared'
import { extend, isArray, isIntegerKey, isMap } from '@vue/shared'
import { EffectScope, recordEffectScope } from './effectScope'
import {
createDep,
@ -276,7 +276,7 @@ export function trigger(
// trigger all effects for target
deps = [...depsMap.values()]
} else if (key === 'length' && isArray(target)) {
const newLength = toNumber(newValue)
const newLength = Number(newValue)
depsMap.forEach((dep, key) => {
if (key === 'length' || key >= newLength) {
deps.push(dep)