Created
March 31, 2010 17:20
-
-
Save dbergey/350591 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
<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