Evan You 11 лет назад
Родитель
Сommit
c711f04d5a

+ 1 - 1
component.json

@@ -26,11 +26,11 @@
     "src/config.js",
     "src/directive.js",
     "src/directives/attr.js",
+    "src/directives/callbacks.js",
     "src/directives/class.js",
     "src/directives/cloak.js",
     "src/directives/component.js",
     "src/directives/el.js",
-    "src/directives/events.js",
     "src/directives/html.js",
     "src/directives/if.js",
     "src/directives/index.js",

+ 3 - 3
src/directives/events.js → src/directives/callbacks.js

@@ -8,8 +8,8 @@ module.exports = {
     var child = this.el.__vue__
     if (!child || this.vm !== child.$parent) {
       _.warn(
-        '`v-events` should only be used on a child component ' +
-        'from the parent template.'
+        '`v-callbacks` should only be used on a child ' +
+        'component from the parent template.'
       )
       return
     }
@@ -18,7 +18,7 @@ module.exports = {
   update: function (handler, oldHandler) {
     if (typeof handler !== 'function') {
       _.warn(
-        'Directive "v-events:' + this.expression + '" ' +
+        'Directive "v-callbacks:' + this.expression + '" ' +
         'expects a function value.'
       )
       return

+ 1 - 1
src/directives/index.js

@@ -19,7 +19,7 @@ exports.repeat     = require('./repeat')
 exports['if']      = require('./if')
 
 // child vm communication directives
-exports.events     = require('./events')
+exports.callbacks  = require('./callbacks')
 
 // internal directives that should not be used directly
 // but we still want to expose them for advanced usage.

+ 7 - 0
src/util/debug.js

@@ -62,6 +62,13 @@ function enableDebug () {
         )
         return
       }
+      if (id === 'events') {
+        exports.warn(
+          'v-events has been deprecated in ^0.12.0. ' +
+          'Use v-callbacks instead.'
+        )
+        return
+      }
     }
     if (!val) {
       exports.warn('Failed to resolve ' + type + ': ' + id)

+ 9 - 9
test/unit/specs/directives/events_spec.js → test/unit/specs/directives/callbacks_spec.js

@@ -2,7 +2,7 @@ var _ = require('../../../../src/util')
 var Vue = require('../../../../src/vue')
 
 if (_.inBrowser) {
-  describe('v-events', function () {
+  describe('v-callbacks', function () {
 
     var el
     beforeEach(function () {
@@ -11,10 +11,10 @@ if (_.inBrowser) {
     })
 
     it('should register events', function () {
-      var spy = jasmine.createSpy('v-events')
+      var spy = jasmine.createSpy('v-callbacks')
       new Vue({
         el: el,
-        template: '<test v-events="test:test"></test>',
+        template: '<test v-callbacks="test:test"></test>',
         methods: {
           test: spy
         },
@@ -32,7 +32,7 @@ if (_.inBrowser) {
     it('should warn when used on non-root node', function () {
       new Vue({
         el: el,
-        template: '<div v-events="test:test"></div>'
+        template: '<div v-callbacks="test:test"></div>'
       })
       expect(hasWarned(_,
         'should only be used on a child component ' +
@@ -40,7 +40,7 @@ if (_.inBrowser) {
     })
 
     it('should warn when used on child component root', function () {
-      var spy = jasmine.createSpy('v-events')
+      var spy = jasmine.createSpy('v-callbacks')
       new Vue({
         el: el,
         template: '<test></test>',
@@ -50,7 +50,7 @@ if (_.inBrowser) {
         components: {
           test: {
             replace: true,
-            template: '<div v-events="test:test"></div>',
+            template: '<div v-callbacks="test:test"></div>',
             compiled: function () {
               this.$emit('test')
             }
@@ -67,7 +67,7 @@ if (_.inBrowser) {
       var vm = new Vue({
         el: el,
         data: { test: 123 },
-        template: '<test v-events="test:test"></test>',
+        template: '<test v-callbacks="test:test"></test>',
         components: {
           test: {}
         }
@@ -79,7 +79,7 @@ if (_.inBrowser) {
       var vm = new Vue({
         el: el,
         data: {a:1},
-        template: '<test v-events="test:a++"></test>',
+        template: '<test v-callbacks="test:a++"></test>',
         components: {
           test: {
             compiled: function () {
@@ -104,7 +104,7 @@ if (_.inBrowser) {
             a++
           }
         },
-        template: '<test v-events="test:handle"></test>',
+        template: '<test v-callbacks="test:handle"></test>',
         components: {
           test: {
             compiled: function () {