Evan You 10 лет назад
Родитель
Сommit
d1ea9b27f4
2 измененных файлов с 19 добавлено и 0 удалено
  1. 7 0
      src/deprecations.js
  2. 12 0
      src/directives/on.js

+ 7 - 0
src/deprecations.js

@@ -163,6 +163,13 @@ if (process.env.NODE_ENV !== 'production') {
         'v-ref or ref can no longer be used on a component root in its own ' +
         'template in 1.0.0. Use it in the parent template instead.'
       )
+    },
+
+    KEY_FILTER: function () {
+      warn(
+        'The "key" filter will be deprecated in 1.0.0. Use the new ' +
+        'on-keyup:key="handler" syntax instead.'
+      )
     }
 
   }

+ 12 - 0
src/directives/on.js

@@ -15,6 +15,18 @@ module.exports = {
       this.key = rawArg.slice(keyIndex + 1)
     }
 
+    // warn old usage
+    if (process.env.NODE_ENV !== 'production') {
+      if (this.filters) {
+        var hasKeyFilter = this.filters.some(function (f) {
+          return f.name === 'key'
+        })
+        if (hasKeyFilter) {
+          _.deprecation.KEY_FILTER()
+        }
+      }
+    }
+
     // deal with iframes
     if (
       this.el.tagName === 'IFRAME' &&