Bug Tracker

Ticket #11291 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 3 years ago by rwaldron

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

comment:3 Changed 3 years ago by timmywil

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to manipulation

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 3 years ago by adebree

jsfiddle for this bug:

 http://jsfiddle.net/bMBgZ/

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 3 years ago by Arne de Bree

  • Status changed from open to closed
  • Resolution set to fixed

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

Changeset: bf7a4df22abcea10cf8f97eb31b5fa989fb4daf5

comment:6 Changed 3 years ago by dmethvin

  • Milestone changed from None to 1.7.2
Note: See TracTickets for help on using tickets.