Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE11 cloneNode behaves unexpectedly #18

Closed
daffl opened this issue Oct 31, 2016 · 1 comment
Closed

IE11 cloneNode behaves unexpectedly #18

daffl opened this issue Oct 31, 2016 · 1 comment

Comments

@daffl
Copy link
Contributor

daffl commented Oct 31, 2016

It turns out that text nodes containing text with a - will be turned into several text nodes in IE11:

var frag = document.createDocumentFragment();
var text = document.createTextNode('some-text');

frag.appendChild(text);

var clone = frag.cloneNode(true);

// clone.childNodes.length -> 3 instead of 1

Due to this we have to fall back to the less performant node cloning already used in IE 9 and 10 for now.

Possible optimizations could be to re-consolidate multiple adjacent text nodes if they initially contained a - (also see Node.normalize).

@phillipskevin
Copy link
Contributor

I found that cloneNode only behaves incorrectly after we set up a MutationObserver on the documentElement.

var frag = document.createDocumentFragment();
var text = document.createTextNode('some-text');
var observer = new MutationObserver(function(mutations) {});

frag.appendChild(text);

var clone = frag.cloneNode(true);
// clone.childNodes.length -> 1

observer.observe(document.documentElement, { childList: true, subtree: true });
clone = frag.cloneNode(true);
// clone.childNodes.length -> 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants