- toggleClass: function( classNames, state ) {
- var type = typeof classNames;
- if ( type === "string" ) {
- // toggle individual class names
- var isBool = typeof state === "boolean", className, i = 0,
- classNames = classNames.split( /\s+/ );
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space seperated list
- state = isBool ? state : !jQuery(this).hasClass( className );
- jQuery(this)[ state ? "addClass" : "removeClass" ]( className );
- }
- } else if ( type === "undefined" || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery.data( this, "__className__", this.className );
- }
- // toggle whole className
- this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || "";
- }
- }
-}, function(name, fn){
- jQuery.fn[ name ] = function(){
- return this.each( fn, arguments );
- };
-});
-
-jQuery.extend({
- attr: function( elem, name, value ) {
- // don't set attributes on text and comment nodes
- if (!elem || elem.nodeType == 3 || elem.nodeType == 8) {
+ attr: function( elem, name, value, pass ) {
+ // don't get/set attributes on text, comment and attribute nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {