Sha256: ecd148ed7e0cb442714f737b682f8bb63abba82fdd9308d189d1472dd528c36e
Contents?: true
Size: 1.15 KB
Versions: 5
Compression:
Stored size: 1.15 KB
Contents
var _ = require('../util') module.exports = { acceptStatement: true, priority: 700, bind: function () { // deal with iframes if ( this.el.tagName === 'IFRAME' && this.arg !== 'load' ) { var self = this this.iframeBind = function () { _.on(self.el.contentWindow, self.arg, self.handler) } _.on(this.el, 'load', this.iframeBind) } }, update: function (handler) { if (typeof handler !== 'function') { _.warn( 'Directive "v-on:' + this.expression + '" ' + 'expects a function value.' ) return } this.reset() var vm = this.vm this.handler = function (e) { e.targetVM = vm vm.$event = e var res = handler(e) vm.$event = null return res } if (this.iframeBind) { this.iframeBind() } else { _.on(this.el, this.arg, this.handler) } }, reset: function () { var el = this.iframeBind ? this.el.contentWindow : this.el if (this.handler) { _.off(el, this.arg, this.handler) } }, unbind: function () { this.reset() _.off(this.el, 'load', this.iframeBind) } }
Version data entries
5 entries across 5 versions & 1 rubygems