Skip to content

Instantly share code, notes, and snippets.

@angus-c
Created June 1, 2011 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angus-c/1001726 to your computer and use it in GitHub Desktop.
Save angus-c/1001726 to your computer and use it in GitHub Desktop.
adding event handler to the <html> element in IE<9 will crash jquery 1.5.2
/*
* probably not good practice to attach event handlers to the <html> element but...
*/
//IE < 9 throws operation not supported error just on property existence check (not function invocation)
typeof $('html')[0]; //"unknown"
$('html')[0].removeAttribute //throws operation not supported error
/************************************************/
//jquery 1.5.2 lines 1503-1516
// Otherwise, we need to eliminate the expando on the node to avoid
// false lookups in the cache for entries that no longer exist
} else if ( isNode ) {
// IE does not allow us to delete expando properties from nodes,
// nor does it have a removeAttribute function on Document nodes;
// we must handle all of these cases
if ( jQuery.support.deleteExpando ) {
delete elem[ jQuery.expando ];
} else if ( elem.removeAttribute ) { // <------------ blows up here
elem.removeAttribute( jQuery.expando );
} else {
elem[ jQuery.expando ] = null;
}
}
@jdalton
Copy link

jdalton commented Jun 1, 2011

I can't seem to reproduce this. I created a small test case here.

@jdalton
Copy link

jdalton commented Jun 1, 2011

Problems like this:

// try in IE
var div = document.createElement('div');
typeof div.offsetParent // unknown
div.offsetParent // boom!

have been address with something like an isHostType method.

@angus-c
Copy link
Author

angus-c commented Jun 1, 2011

Yeah I can only reproduce it sporadically too. Need to do more digging. Thanks for the test case.

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