Created
October 24, 2011 14:57
-
-
Save timmywil/1309242 to your computer and use it in GitHub Desktop.
IE calls methods simply when accessed. This is not always an issue, but can be problematic. Below is a failing test case using XML. This issue warrants the need for other ways to check for the presence of methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xml = $.parseXML('<crazy><element>asdf</element><div>asdf</div></crazy>'), | |
counter = 0; | |
console.log( xml, $(xml).find('*') ); | |
$(xml).find('*').andSelf().each(function( i, elem ) { | |
if ( elem.getElementsByTagName ) { | |
counter++; | |
} | |
}); | |
console.log( counter ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsperf.com/in-vs-typeof