Просмотр исходного кода

expose oldValue on directive bindings

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

+ 1 - 0
flow/vnode.js

@@ -55,6 +55,7 @@ declare interface VNodeData {
 declare type VNodeDirective = {
   name: string,
   value?: any,
+  oldValue?: any,
   arg?: string,
   modifiers?: { [key: string]: boolean }
 }

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

@@ -30,7 +30,7 @@ function applyDirectives (
       if (fn) {
         // only call update if value has changed
         if (isUpdate && oldDirs) {
-          const oldValue = oldDirs[i].value
+          const oldValue = dir.oldValue = oldDirs[i].value
           if (oldValue === dir.value) {
             continue
           }