ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

.html() crash in IE6–8 with unknown (HTML5) elements. #29

Closed BenWard closed 12 years ago

BenWard commented 13 years ago

Attempting to write innerHTML or appendChild to an unknown element in old versions of IE results in an Unknown runtime error from those browsers (even if the element is declared using document.createElement('time') previously.)

e.g.

var $t = $('time')
$t.html("10 minutes ago")

Will trigger the error in IE.

Might be worth looking at @jdbartlett's innerShiv, although I think that may only handle the creation of unknown/HTML5 elements within elements that are already functional nodes, rather than the enabling of DOM functionality on those unknown elements.

ded commented 13 years ago

Investigating

ded commented 13 years ago

do you get the same error when doing this?

var $t = jQuery('time')
$t.html("10 minutes ago")
BenWard commented 13 years ago

I've been working on a whole test-case page for this (bonzo+qwery, compared to JQuery, compared to raw DOM) and I'll attach that somewhere shortly. In short though, it depends on how the element is created. If it's already in the DOM (either statically in the page, or via setting a parent innerHTML the scripting functionality of the node is dysfunctional.

It's not quite analogous to the CSS styling shim though, since I believe that just requires creating the element once, and all future elements are recognised by the CSS parser, with this, it's only the explicitly created elements that have the expected functionality.

I'll share the test case page when I get back to the other computer. It's goofy, and I can believe it's not sanely fixable (the only thing might be to find a way to have the lib handle errors more gracefully.)