jquery core: closes #2930. Normalizing attr() to return undefined, even when getting DOM attributes.

This commit is contained in:
Ariel Flesler 2008-05-24 18:09:21 +00:00
parent 7f27816d30
commit cff5323a1d

View File

@ -1060,7 +1060,7 @@ jQuery.extend({
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
// If applicable, access the attribute via the DOM 0 way // If applicable, access the attribute via the DOM 0 way
if ( notxml && !special && name in elem ) { if ( name in elem && notxml && !special ) {
if ( set ){ if ( set ){
// We can't allow the type property to be changed (since it causes problems in IE) // We can't allow the type property to be changed (since it causes problems in IE)
if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
@ -1083,11 +1083,13 @@ jQuery.extend({
// convert the value to a string (all browsers do this but IE) see #1070 // convert the value to a string (all browsers do this but IE) see #1070
elem.setAttribute( name, "" + value ); elem.setAttribute( name, "" + value );
if ( msie && special && notxml ) var attr = msie && notxml && special
return elem.getAttribute( name, 2 ); // Some attributes require a special call on IE
? elem.getAttribute( name, 2 )
return elem.getAttribute( name ); : elem.getAttribute( name );
// Non-existent attributes return null, we normalize to undefined
return attr === null ? undefined : attr;
} }
// elem is actually elem.style ... set the style // elem is actually elem.style ... set the style