Evan You 10 лет назад
Родитель
Сommit
8f274a3324
2 измененных файлов с 4 добавлено и 2 удалено
  1. 2 0
      src/compiler/helpers.js
  2. 2 2
      src/core/vdom/modules/directives.js

+ 2 - 0
src/compiler/helpers.js

@@ -29,6 +29,7 @@ export function addDirective (
 export function addHook (el: ASTElement, name: string, code: string) {
   const hooks = el.hooks || (el.hooks = {})
   const hook = hooks[name]
+  /* istanbul ignore if */
   if (hook) {
     hook.push(code)
   } else {
@@ -50,6 +51,7 @@ export function addHandler (
   }
   const newHandler = { value, modifiers }
   const handlers = events[name]
+  /* istanbul ignore if */
   if (Array.isArray(handlers)) {
     handlers.push(newHandler)
   } else if (handlers) {

+ 2 - 2
src/core/vdom/modules/directives.js

@@ -23,9 +23,9 @@ function applyDirectives (
   hook: string
 ) {
   const dirs = vnode.data.directives
-  const oldDirs = oldVnode.data.directives
-  const isUpdate = hook === 'update'
   if (dirs) {
+    const oldDirs = oldVnode.data.directives
+    const isUpdate = hook === 'update'
     for (let i = 0; i < dirs.length; i++) {
       const dir = dirs[i]
       const def = resolveAsset(vnode.context.$options, 'directives', dir.name, true)