refactor: use isArray function from shared (#441)
This commit is contained in:
parent
6f9d9e7095
commit
d7d87622ce
@ -1,4 +1,4 @@
|
|||||||
import { NO, makeMap } from '@vue/shared'
|
import { NO, makeMap, isArray } from '@vue/shared'
|
||||||
import {
|
import {
|
||||||
ErrorCodes,
|
ErrorCodes,
|
||||||
createCompilerError,
|
createCompilerError,
|
||||||
@ -203,7 +203,7 @@ function parseChildren(
|
|||||||
node = parseText(context, mode)
|
node = parseText(context, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(node)) {
|
if (isArray(node)) {
|
||||||
for (let i = 0; i < node.length; i++) {
|
for (let i = 0; i < node.length; i++) {
|
||||||
pushNode(nodes, node[i])
|
pushNode(nodes, node[i])
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { OperationTypes } from './operations'
|
import { OperationTypes } from './operations'
|
||||||
import { Dep, targetMap } from './reactive'
|
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> {
|
export interface ReactiveEffect<T = any> {
|
||||||
(): T
|
(): T
|
||||||
@ -170,7 +170,7 @@ export function trigger(
|
|||||||
}
|
}
|
||||||
// also run for iteration key on ADD | DELETE
|
// also run for iteration key on ADD | DELETE
|
||||||
if (type === OperationTypes.ADD || type === OperationTypes.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))
|
addRunners(effects, computedRunners, depsMap.get(iterationKey))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { isArray } from '@vue/shared'
|
||||||
import { TestElement } from './nodeOps'
|
import { TestElement } from './nodeOps'
|
||||||
|
|
||||||
export function triggerEvent(
|
export function triggerEvent(
|
||||||
@ -9,7 +10,7 @@ export function triggerEvent(
|
|||||||
if (eventListeners) {
|
if (eventListeners) {
|
||||||
const listener = eventListeners[event]
|
const listener = eventListeners[event]
|
||||||
if (listener) {
|
if (listener) {
|
||||||
if (Array.isArray(listener)) {
|
if (isArray(listener)) {
|
||||||
for (let i = 0; i < listener.length; i++) {
|
for (let i = 0; i < listener.length; i++) {
|
||||||
listener[i](...payload)
|
listener[i](...payload)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user