aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriel Flesler <aflesler@gmail.com>2008-05-24 18:09:21 +0000
committerAriel Flesler <aflesler@gmail.com>2008-05-24 18:09:21 +0000
commitcff5323a1de17423e231b01c7fa8ebe31a62cf5e (patch)
tree04896125408c166969c6c7374381f2d885c4f6ef
parent7f27816d3068bff70eecfcf18366b54345750efe (diff)
downloadjquery-cff5323a1de17423e231b01c7fa8ebe31a62cf5e.tar.gz
jquery-cff5323a1de17423e231b01c7fa8ebe31a62cf5e.zip
jquery core: closes #2930. Normalizing attr() to return undefined, even when getting DOM attributes.
-rw-r--r--src/core.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core.js b/src/core.js
index d46f89d16..478de971d 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1060,7 +1060,7 @@ jQuery.extend({
elem.parentNode.selectedIndex;
// If applicable, access the attribute via the DOM 0 way
- if ( notxml && !special && name in elem ) {
+ if ( name in elem && notxml && !special ) {
if ( set ){
// 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 )
@@ -1083,11 +1083,13 @@ jQuery.extend({
// convert the value to a string (all browsers do this but IE) see #1070
elem.setAttribute( name, "" + value );
- if ( msie && special && notxml )
- return elem.getAttribute( name, 2 );
-
- return elem.getAttribute( name );
+ var attr = msie && notxml && special
+ // Some attributes require a special call on IE
+ ? elem.getAttribute( name, 2 )
+ : 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