Bug Tracker

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#10427 closed bug (invalid)

Creating custom elements is broken on IE7 and 8 using $('<...>').

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 Rick Waldron)

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 (20)

comment:1 Changed 6 years ago by ajpiano

Resolution: duplicate
Status: newclosed

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!

comment:2 Changed 6 years ago by ajpiano

Duplicate of #6485.

comment:3 Changed 6 years ago by bmustiata

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:

  1. 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.
  2. 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 6 years ago by ajpiano

Component: unfiledmanipulation
Keywords: 1.8-discuss added
Milestone: None1.8
Resolution: duplicate
Status: closedreopened

comment:5 Changed 6 years ago by ajpiano

Version: 1.6.41.7b1

comment:6 Changed 6 years ago by ajpiano

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 6 years ago by dmethvin

Status: reopenedopen

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 6 years ago by Rick Waldron

@dmethvin I'm not sure it behooves us to try to support all magic.

comment:9 Changed 6 years ago by ajpiano

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 6 years ago by Rick Waldron

comment:11 Changed 6 years ago by Rick Waldron

just kidding. that won't work. back to the drawing board.

comment:12 Changed 6 years ago by anonymous

@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 6 years ago by Rick Waldron

Owner: set to Rick Waldron
Status: openassigned

comment:14 Changed 6 years ago by jaubourg

Description: modified (diff)

+0

comment:15 Changed 6 years ago by dmethvin

Description: modified (diff)

-1, HTML5 defines the tags we need to support. Adding custom tags smells like an ad-hoc attempt at parsing arbitrary XML using IE's tag-soup parser. Use a supported format like JSON instead.

comment:16 Changed 6 years ago by mikesherov

Description: modified (diff)

+0, I'll punt to rwaldron on this one.

comment:17 Changed 6 years ago by timmywil

-1, I'd rather follow spec

comment:18 Changed 6 years ago by Rick Waldron

Description: modified (diff)

+0, I want to revisit this and all the test cases involved.

comment:19 Changed 5 years ago by Rick Waldron

Resolution: invalid
Status: assignedclosed

This is no longer valid. The latest version of html5shim actually builds support into document.createElement directly.

comment:20 Changed 5 years ago by dmethvin

Milestone: 1.8
Note: See TracTickets for help on using tickets.