Created
April 24, 2014 19:11
-
-
Save mgimenez/11265993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (win, doc) { | |
'use strict'; | |
var bind = win.addEventListener ? 'addEventListener' : 'attachEvent', | |
unbind = win.removeEventListener ? 'removeEventListener' : 'detachEvent', | |
prefix = (bind !== 'addEventListener') ? 'on' : '', | |
cho = win.cho || {}; | |
/** | |
* Created by https://github.com/component/event/blob/master/index.js | |
* @param {Element} el | |
* @param {String} type | |
* @param {Function} fn | |
* @param {Boolean} capture | |
* @return {Function} | |
* @see https://github.com/component/event/blob/master/index.js | |
*/ | |
cho.bind = function (el, type, fn, capture) { | |
el[bind](prefix + type, fn, capture || false); | |
return fn; | |
}; | |
/** | |
* Created by https://github.com/component/event/blob/master/index.js | |
* @param {Element} el | |
* @param {String} type | |
* @param {Function} fn | |
* @param {Boolean} capture | |
* @return {Function} | |
* @api public | |
*/ | |
cho.unbind = function (el, type, fn, capture) { | |
el[unbind](prefix + type, fn, capture || false); | |
return fn; | |
}; | |
}(this, this.document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment