Minor adjustments and cleanup, including normalizing the value to a string when setting( list of changes below )
- Normalize set value to string to synchronize return type cross-browser - Add style attrHook to propHooks to support style getting in all browsers for both attr and prop - Extend the selected propHook instead of overriding a possible set function - Remove selected propHook TODO since there is no selected content attribute and it should return null
This commit is contained in:
parent
8cbf551a48
commit
ff75767558
|
@ -313,7 +313,7 @@ jQuery.extend({
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
elem.setAttribute( name, value );
|
elem.setAttribute( name, "" + value );
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,10 +440,8 @@ if ( !jQuery.support.getSetAttribute ) {
|
||||||
var ret = elem.getAttributeNode( name );
|
var ret = elem.getAttributeNode( name );
|
||||||
if ( ret ) {
|
if ( ret ) {
|
||||||
ret.nodeValue = value;
|
ret.nodeValue = value;
|
||||||
} else {
|
return value;
|
||||||
elem.setAttribute( name, value );
|
|
||||||
}
|
}
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -458,9 +456,6 @@ jQuery.each([ "selected", "checked", "readonly", "disabled" ], function( i, name
|
||||||
jQuery.removeAttr( elem, name );
|
jQuery.removeAttr( elem, name );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.setAttribute( name, value );
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -477,7 +472,7 @@ if ( !jQuery.support.hrefNormalized ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !jQuery.support.style ) {
|
if ( !jQuery.support.style ) {
|
||||||
jQuery.attrHooks.style = {
|
jQuery.propHooks.style = jQuery.attrHooks.style = {
|
||||||
get: function( elem ) {
|
get: function( elem ) {
|
||||||
return elem.style.cssText;
|
return elem.style.cssText;
|
||||||
},
|
},
|
||||||
|
@ -490,24 +485,20 @@ if ( !jQuery.support.style ) {
|
||||||
// Safari mis-reports the default selected property of an option
|
// Safari mis-reports the default selected property of an option
|
||||||
// Accessing the parent's selectedIndex property fixes it
|
// Accessing the parent's selectedIndex property fixes it
|
||||||
if ( !jQuery.support.optSelected ) {
|
if ( !jQuery.support.optSelected ) {
|
||||||
|
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
|
||||||
jQuery.propHooks.selected = {
|
|
||||||
get: function( elem ) {
|
get: function( elem ) {
|
||||||
var parent = elem.parentNode;
|
var parent = elem.parentNode;
|
||||||
|
|
||||||
if ( parent ) {
|
if ( parent ) {
|
||||||
parent.selectedIndex;
|
parent.selectedIndex;
|
||||||
|
|
||||||
// TODO: We may need an attrHook for selected that simply defers to prop?
|
|
||||||
// The attr is undefined if the option is created with createElement and not on the DOM
|
|
||||||
|
|
||||||
// Make sure that it also works with optgroups, see #5701
|
// Make sure that it also works with optgroups, see #5701
|
||||||
if ( parent.parentNode ) {
|
if ( parent.parentNode ) {
|
||||||
parent.parentNode.selectedIndex;
|
parent.parentNode.selectedIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
Loading…
Reference in a new issue