Skip to content
Permalink
Browse files
Fix #12945. Check for .getAttribute so IE9 is happy.
  • Loading branch information
dmethvin committed Jan 4, 2013
1 parent abead1c commit a95f35744aff95a446cc05e1d8c558b3a4867836
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/attributes.js
@@ -330,7 +330,11 @@ jQuery.extend({

} else {

ret = elem.getAttribute( name );
// In IE9+, Flash objects don't have .getAttribute (#12945)
// Support: IE9+
if ( typeof elem.getAttribute !== "undefined" ) {
ret = elem.getAttribute( name );
}

// Non-existent attributes return null, we normalize to undefined
return ret == null ?

3 comments on commit a95f357

@nuxodin

This comment has been minimized.

Copy link

@nuxodin nuxodin replied Jan 9, 2013

why not simply this?

if( elem.getAttribute ){
...
}

@dmethvin

This comment has been minimized.

Copy link
Member Author

@dmethvin dmethvin replied Jan 9, 2013

Flash objects aren't native JavaScript objects, they're host objects built off Microsoft COM. They did it wrong and don't understand the difference between a property reference and a function call. Checking for falsy via elem.getAttribute actually calls the method with no arguments. The typeof gets around that. This problem also happens with DOM objects in IE8 and lower.

@nuxodin

This comment has been minimized.

Copy link

@nuxodin nuxodin replied Jan 9, 2013

Interesting, thank you

Please sign in to comment.