refactor(errorHandlling): handle array in callWithAsyncErrorHandling (#332)

This commit is contained in:
Jooger
2019-10-22 01:59:10 +08:00
committed by Evan You
parent 74d8c5919d
commit 67eb29f63b
4 changed files with 32 additions and 60 deletions

View File

@@ -20,7 +20,6 @@ import {
isFunction,
capitalize,
NOOP,
isArray,
isObject,
NO,
makeMap,
@@ -196,23 +195,12 @@ export function createComponentInstance(
const props = instance.vnode.props || EMPTY_OBJ
const handler = props[`on${event}`] || props[`on${capitalize(event)}`]
if (handler) {
if (isArray(handler)) {
for (let i = 0; i < handler.length; i++) {
callWithAsyncErrorHandling(
handler[i],
instance,
ErrorCodes.COMPONENT_EVENT_HANDLER,
args
)
}
} else {
callWithAsyncErrorHandling(
handler,
instance,
ErrorCodes.COMPONENT_EVENT_HANDLER,
args
)
}
callWithAsyncErrorHandling(
handler,
instance,
ErrorCodes.COMPONENT_EVENT_HANDLER,
args
)
}
}
}