Skip to content

Commit

Permalink
Adjust the directive code according to the v-on changes
Browse files Browse the repository at this point in the history
  • Loading branch information
simplesmiler committed Nov 10, 2015
1 parent 5e624e4 commit 34e19a0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions directive.js
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
var _ = require('vue').util;

// @NOTE: written with regard to `v-on`
// @REFERENCE: https://github.com/yyx990803/vue/blob/0.12.14/src/directives/on.js
// @REFERENCE: https://github.com/vuejs/vue/blob/1.0.0/src/directives/public/on.js

module.exports = {

Expand All @@ -12,8 12,9 @@ module.exports = {
if (typeof handler !== 'function') {
if (process.env.NODE_ENV !== 'production') {
_.warn(
'Directive ' this.name '="' this.expression '" '
'expects a function value, got ' handler
this.name '="'
this.expression '" expects a function value, '
'got ' handler
);
}
return;
Expand All @@ -22,16 23,15 @@ module.exports = {
this.reset();

var self = this;
var vm = this.vm;
var scope = this._scope || this.vm;

this.handler = function(ev) {
// @NOTE: IE 5.0
// @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
if (!self.el.contains(ev.target)) {
ev.targetVM = vm;
vm.$event = ev;
scope.$event = ev;
var res = handler(ev);
vm.$event = null;
scope.$event = null;
return res;
}
};
Expand Down

0 comments on commit 34e19a0

Please sign in to comment.