Opened 12 years ago
Last modified 11 years ago
#10427 closed bug
Creating custom elements is broken on IE7 and 8 using $('<...>'). — at Version 14
Reported by: | bmustiata | Owned by: | Rick Waldron |
---|---|---|---|
Priority: | undecided | Milestone: | |
Component: | manipulation | Version: | 1.7b1 |
Keywords: | 1.8-discuss | Cc: | |
Blocked by: | Blocking: |
Description (last modified by )
Fiddle test case: http://jsfiddle.net/nmfCy/1/
Proposed Patch: http://download.androidknight.com/jquery-custom-elements-1.6.4.patch
Full-Original: http://download.androidknight.com/jquery-1.6.4-original.js
Full-Patched : http://download.androidknight.com/jquery-1.6.4-patched.js
Description. The expected nodes to be added is: <customelement>
However in IE7/8 (IE9 works fine) two elements get created after innerHtml is set: <customelement>
and
</customelement> (!!) - yes, with the beginning slash character as tagName,
and all the content that should belong in the <customelement> is now a sibling living between the two elements.
This needs to work, since the HTML5 elements do match the criteria of unknown elements, and creating them programatically now breaks the DOM structure in IE7/8 (same example but with a canvas element instead: http://jsfiddle.net/nmfCy/2/).
To make matters worse the added elements (via innerHtml) are unknown html elements, that do not allow creating child elements into them.
However, if we create the same element with document.createElement('customelement') and we append this one to the DOM, we can add children elements into it.
The given patch adds the check for custom elements support, and if it does not exists, it then attempts to find and fix the eventually broken newly created custom elements (in the clean method).
The patch was tested against IE7, IE8, IE9, Chrome 14.0 and Firefox 7.0.1.
Change History (14)
comment:1 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:3 Changed 12 years ago by
If I may, I think this issue should be reopened to really support unknown elements for IE7/8. The problem is that the current implementation has a list of unknown elements.
This causes in my view (at least) two problems:
- If tomorrow html5 decide to add a new element, old versions of the applications that use the current jQuery version will suddenly stop working until they upgrade their jQuery, and for any new element this list must be upgraded.
- This approach also doesn't allow custom elements to be created that are not (and will never be) part of HTML5. We are actually using this in an application, where we create custom rendered metadata nodes on the fly (we receive them via AJAX). Elements are things like <loop>, <metatarget>, etc.
I am currently working on a fork where I try to allow creation of completely unknown elements, because currently (in the 1.7 beta):
jQuery('<customelement>some content</customelement>');
has a different outcome in IE8 than in IE9 (or any other decent browser).
I hope you find these requirements acceptable for reopening this. (since HTML5 support is implemented, and only custom elements are not working).
comment:4 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Keywords: | 1.8-discuss added |
Milestone: | None → 1.8 |
Resolution: | duplicate |
Status: | closed → reopened |
comment:5 Changed 12 years ago by
Version: | 1.6.4 → 1.7b1 |
---|
comment:6 Changed 12 years ago by
Reopening for inclusion in 1.8 features discussion - it's too late and this feature is too different than HTML5 support for this to be included in 1.7.
comment:7 Changed 12 years ago by
Status: | reopened → open |
---|
Marking as valid to get it out of the unreviewed bugs list. IMO we should only support heroic measures for HTML5 tags, as we do now in 1.7.
comment:8 Changed 12 years ago by
@dmethvin I'm not sure it behooves us to try to support all magic.
comment:9 Changed 12 years ago by
what if the list of shiv'd elements had a fixHooks-esque accessible list for users to add more elements beyond the HTML5 set, but sparing us the possibility of shving on the fly?
comment:10 Changed 12 years ago by
Based on @ajpiano's idea https://github.com/rwldrn/jquery/pull/new/10427
comment:12 Changed 12 years ago by
@ajpiano: Should be fine with adding them via hooks.
Thus based on @ajpiano's and @rwaldron's idea: https://github.com/jquery/jquery/pull/533
comment:13 Changed 12 years ago by
Owner: | set to Rick Waldron |
---|---|
Status: | open → assigned |
Thanks for your time and interest in helping out the jQuery project - you're right that this is a big issue, and a high priority one for us to solve. However, we already did that, and it's already available in the jQuery 1.7 beta. Given your interest in this issue, we'd appreciate your taking that for a spin. Thanks!