refactor: use isArray function from shared (#441)

This commit is contained in:
QuincyChen 2019-11-08 22:52:24 +08:00 committed by Evan You
parent 6f9d9e7095
commit d7d87622ce
3 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { NO, makeMap } from '@vue/shared'
import { NO, makeMap, isArray } from '@vue/shared'
import {
ErrorCodes,
createCompilerError,
@ -203,7 +203,7 @@ function parseChildren(
node = parseText(context, mode)
}
if (Array.isArray(node)) {
if (isArray(node)) {
for (let i = 0; i < node.length; i++) {
pushNode(nodes, node[i])
}

View File

@ -1,6 +1,6 @@
import { OperationTypes } from './operations'
import { Dep, targetMap } from './reactive'
import { EMPTY_OBJ, extend } from '@vue/shared'
import { EMPTY_OBJ, extend, isArray } from '@vue/shared'
export interface ReactiveEffect<T = any> {
(): T
@ -170,7 +170,7 @@ export function trigger(
}
// also run for iteration key on ADD | DELETE
if (type === OperationTypes.ADD || type === OperationTypes.DELETE) {
const iterationKey = Array.isArray(target) ? 'length' : ITERATE_KEY
const iterationKey = isArray(target) ? 'length' : ITERATE_KEY
addRunners(effects, computedRunners, depsMap.get(iterationKey))
}
}

View File

@ -1,3 +1,4 @@
import { isArray } from '@vue/shared'
import { TestElement } from './nodeOps'
export function triggerEvent(
@ -9,7 +10,7 @@ export function triggerEvent(
if (eventListeners) {
const listener = eventListeners[event]
if (listener) {
if (Array.isArray(listener)) {
if (isArray(listener)) {
for (let i = 0; i < listener.length; i++) {
listener[i](...payload)
}