Skip to main content

Bug Tracker

Side navigation

#11291 closed bug (fixed)

Opened February 06, 2012 07:18PM UTC

Closed February 10, 2012 01:51AM UTC

Last modified February 10, 2012 01:59AM UTC

Cloning XMLDoc's with HTML5 nodeName's breaks on IE

Reported by: adebree Owned by:
Priority: low Milestone: 1.7.2
Component: manipulation Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

For example:

var xmlStr = "<root><meter /></root>";
var xmlDoc = jQuery.parseXML( xmlStr );
var $xmlDoc = jQuery( xmlDoc );

var $meter = $xmlDoc.find( "meter" ).clone();

Due to "meter" being in the list of HTML5 nodeNames jQuery incorrectly uses the shimCloneNode() function for cloning. This results in $meter being a textNode (nodeType 3) and having the data 'undefined'.

And since the regex to detect the node names is only checking the start of the node name this also causes problems for elements in a HTMLDoc like <metering />

Patch is already done, will place a pull request.

Attachments (0)
Change History (6)

Changed February 06, 2012 07:24PM UTC by rwaldron comment:1

This is actually a good argument for the removal of shimCloneNode and createSafeFragment

Changed February 06, 2012 09:02PM UTC by adebree comment:2

Changed February 06, 2012 09:18PM UTC by timmywil comment:3

component: unfiledmanipulation
priority: undecidedlow
status: newopen

This is valid, but please provide a test case on to demonstrate the issue in this ticket.

@rwaldron: I think jQuery should be able to work without html5shim.

Changed February 06, 2012 09:40PM UTC by adebree comment:4

jsfiddle for this bug:

Run in IE8 or lower and the nodeType will be 3 instead of the expected 1 showing the clone() does not properly take place.

Changed February 10, 2012 01:51AM UTC by Arne de Bree comment:5

resolution: → fixed
status: openclosed

Fix #11291. Always clone XML docs with a genuine .cloneNode().

Changeset: bf7a4df22abcea10cf8f97eb31b5fa989fb4daf5

Changed February 10, 2012 01:59AM UTC by dmethvin comment:6

milestone: None1.7.2