cloneNode(true) skips nodes: unreliable

Fixed Issue #15839308

Details

Author
Andrea G.
Created
Feb 7, 2018
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Internet Explorer
Standard affected
DOM Standard

Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

The following code fails only in IE/Edge browsers.
The exact clone of a node or fragment is expected to have exact amount of nodes, even if empty, in order to work without issues in HTMLTemplateElement based libraries such hyperHTML, lit-html, or others.

IE/Edge carry this wrong behavior since ever and require special patching that slows it down consistently compared to every other browser.

var fragment = document.createDocumentFragment();
fragment.appendChild(document.createTextNode(‘?’));
fragment.appendChild(document.createTextNode(‘’));
fragment.childNodes.length; // 2
fragment.childNodes[0].textContent; // “?”
fragment.childNodes[1].textContent; // “”

// the cloneNode(true) forgets the empty childNode
var fake = fragment.cloneNode(true);
fake.childNodes.length; // 1
fake.childNodes[0].textContent; // “?”

Attachments

1 attachment

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Steven K.”

  • Hi Andrea,

    I am not able to repro this issue in 16299.192.  Will you provide the extended version of Windows 10 you are using?  Win + S and type “winver” and hit enter.

    I have attached my repro file as the website likes to convert quotation marks.  Verify that my repro is a proper repro.

    Appreciate the support,

    Steve

  • Microsoft Edge Team

    Changed Status to “Fixed”

You need to sign in to your Microsoft account to add a comment.

Sign in