Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@jdalton jdalton commented Jun 1, 2011

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

@jdalton

This comment has been minimized.

Copy link

@jdalton 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

This comment has been minimized.

Copy link
Owner Author

@angus-c 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