|
|
@ -1,4 +1,4 @@ |
|
|
import { isObject } from 'underscore'; |
|
|
import { isObject, isString, each, isUndefined } from 'underscore'; |
|
|
|
|
|
|
|
|
module.exports = ({ $, Backbone }) => { |
|
|
module.exports = ({ $, Backbone }) => { |
|
|
if (Backbone) { |
|
|
if (Backbone) { |
|
|
@ -177,11 +177,36 @@ module.exports = ({ $, Backbone }) => { |
|
|
return this; |
|
|
return this; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
(fn.remove = function() { |
|
|
// For SVGs in IE
|
|
|
return this.each(node => { |
|
|
(fn.removeClass = function(c) { |
|
|
return node.parentNode && node.parentNode.removeChild(node); |
|
|
if (!arguments.length) { |
|
|
}); |
|
|
return this.attr('class', ''); |
|
|
|
|
|
} |
|
|
|
|
|
const classes = isString(c) && c.match(/\S+/g); |
|
|
|
|
|
return classes |
|
|
|
|
|
? this.each(function(el) { |
|
|
|
|
|
each(classes, function(c) { |
|
|
|
|
|
if (el.classList) { |
|
|
|
|
|
el.classList.remove(c); |
|
|
|
|
|
} else { |
|
|
|
|
|
const val = el.className; |
|
|
|
|
|
const bval = el.className.baseVal; |
|
|
|
|
|
|
|
|
|
|
|
if (!isUndefined(bval)) { |
|
|
|
|
|
val.baseVal = bval.replace(c, ''); |
|
|
|
|
|
} else { |
|
|
|
|
|
el.className = val.replace(c, ''); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
: this; |
|
|
}), |
|
|
}), |
|
|
|
|
|
(fn.remove = function() { |
|
|
|
|
|
return this.each(node => { |
|
|
|
|
|
return node.parentNode && node.parentNode.removeChild(node); |
|
|
|
|
|
}); |
|
|
|
|
|
}), |
|
|
// For spectrum compatibility
|
|
|
// For spectrum compatibility
|
|
|
(fn.bind = function(ev, h) { |
|
|
(fn.bind = function(ev, h) { |
|
|
return this.on(ev, h); |
|
|
return this.on(ev, h); |
|
|
|