-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.js
36 lines (30 loc) · 771 Bytes
/
events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var _ = require('../util')
module.exports = {
acceptStatement: true,
bind: function () {
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.'
)
return
}
},
update: function (handler, oldHandler) {
if (typeof handler !== 'function') {
_.warn(
'Directive "v-events:' + this.expression + '" ' +
'expects a function value.'
)
return
}
var child = this.el.__vue__
if (oldHandler) {
child.$off(this.arg, oldHandler)
}
child.$on(this.arg, handler)
}
// when child is destroyed, all events are turned off,
// so no need for unbind here.
}