]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(directives): ignore invalid directive hooks
authorEvan You <yyx990803@gmail.com>
Tue, 3 Mar 2020 18:26:32 +0000 (12:26 -0600)
committerEvan You <yyx990803@gmail.com>
Tue, 3 Mar 2020 18:26:48 +0000 (12:26 -0600)
fix #795

packages/runtime-core/src/directives.ts

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