Last active
August 29, 2015 14:07
-
-
Save metaist/00ad964bd78cc19afcb8 to your computer and use it in GitHub Desktop.
jQuery.removeClass, but allow regular expressions.
This file contains hidden or 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 (factory) { | |
'use strict'; | |
if ('function' === typeof define && define.amd) { | |
define(['jquery'], factory); // register anonymous AMD module | |
} else { factory(jQuery); } // browser globals | |
}(function (jQuery) { | |
'use strict'; | |
var | |
$ = jQuery, | |
orig = $.fn.removeClass, | |
better = function (value) { | |
if ('regexp' !== $.type(value)) { return orig.apply(this, arguments); } | |
return orig.call(this, function (index, className) { | |
return (className.match(value) || []).join(' '); | |
}); | |
}; | |
better.noConflict = function () { | |
$.fn.extend({removeClass: orig}); | |
return better; | |
}; | |
$.fn.extend({ removeClass: better }); | |
// export the plugin | |
return $.fn.removeClass; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment