Skip to content

Instantly share code, notes, and snippets.

@dbergey
Created March 31, 2010 17:20
Show Gist options
  • Save dbergey/350591 to your computer and use it in GitHub Desktop.
Save dbergey/350591 to your computer and use it in GitHub Desktop.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// jquery error checking plugin
(function($) {
errors = {
test: function() {
var args = $.makeArray(arguments);
var msg, test = args.shift();
if ( msg = errors.tests[test].apply(this, args) ) throw msg;
},
tests: {
classNameFormat: function (a) { return !a.match(/^\./) || 'jQuery: Incorrect leading dot in class name: '+a; }
}
};
$.fn.extend({
_addClass: $.fn.addClass,
addClass: function(value) {
errors.test('classNameFormat', value);
return this._addClass.apply(this, arguments);
}
});
})(jQuery);
jQuery(function($) {
$('body').addClass('.red');
$('body').addClass('red');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment