Skip to content

Instantly share code, notes, and snippets.

@timmywil
Created October 24, 2011 14:57
Show Gist options
  • Save timmywil/1309242 to your computer and use it in GitHub Desktop.
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.
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 );
@timmywil
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment