fix(directives): ignore invalid directive hooks

fix #795
This commit is contained in:
Evan You 2020-03-03 12:26:32 -06:00
parent 27afbaf02d
commit 7971b0468c

View File

@ -126,8 +126,9 @@ export function withDirectives<T extends VNode>(
} }
// inject onVnodeXXX hooks // inject onVnodeXXX hooks
for (const key in dir) { for (const key in dir) {
if (!injected[key]) { const mapped = directiveToVnodeHooksMap[key]
const { 0: hookName, 1: hook } = directiveToVnodeHooksMap[key] if (mapped && !injected[key]) {
const { 0: hookName, 1: hook } = mapped
const existing = props[hookName] const existing = props[hookName]
props[hookName] = existing ? [].concat(existing, hook as any) : hook props[hookName] = existing ? [].concat(existing, hook as any) : hook
injected[key] = true injected[key] = true