Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11291 closed bug (fixed)

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.

Change History (6)

comment:1 Changed 11 years ago by Rick Waldron

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

comment:3 Changed 11 years ago by Timmy Willison

Component: unfiledmanipulation
Priority: undecidedlow
Status: newopen

This is valid, but please provide a test case on http://jsfiddle.net to demonstrate the issue in this ticket.

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

comment:4 Changed 11 years ago by adebree

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.

comment:5 Changed 11 years ago by Arne de Bree

Resolution: fixed
Status: openclosed

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

Changeset: bf7a4df22abcea10cf8f97eb31b5fa989fb4daf5

comment:6 Changed 11 years ago by dmethvin

Milestone: None1.7.2
Note: See TracTickets for help on using tickets.