first commit
This commit is contained in:
40
bootstrap/node_modules/event-component/index.js
generated
vendored
Normal file
40
bootstrap/node_modules/event-component/index.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
/**
|
||||
* Bind `el` event `type` to `fn`.
|
||||
*
|
||||
* @param {Element} el
|
||||
* @param {String} type
|
||||
* @param {Function} fn
|
||||
* @param {Boolean} capture
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.bind = function(el, type, fn, capture){
|
||||
if (el.addEventListener) {
|
||||
el.addEventListener(type, fn, capture);
|
||||
} else {
|
||||
el.attachEvent('on' + type, fn);
|
||||
}
|
||||
return fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unbind `el` event `type`'s callback `fn`.
|
||||
*
|
||||
* @param {Element} el
|
||||
* @param {String} type
|
||||
* @param {Function} fn
|
||||
* @param {Boolean} capture
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.unbind = function(el, type, fn, capture){
|
||||
if (el.removeEventListener) {
|
||||
el.removeEventListener(type, fn, capture);
|
||||
} else {
|
||||
el.detachEvent('on' + type, fn);
|
||||
}
|
||||
return fn;
|
||||
};
|
Reference in New Issue
Block a user