Copy all SVG child nodes when using setting innerHTML in IE (#7618)

This commit is contained in:
Paul O’Shannessy
2016-08-31 11:50:58 -07:00
committed by GitHub
parent 51476de913
commit c73d8633c3
2 changed files with 6 additions and 4 deletions
@@ -25,7 +25,9 @@ describe('setInnerHTML', function() {
});
describe('when the node does not have an innerHTML property', () => {
it('sets innerHTML on it', function() {
// Disabled. JSDOM doesn't seem to remove nodes when using appendChild to
// move existing nodes.
xit('sets innerHTML on it', function() {
// Create a mock node that looks like an SVG in IE (without innerHTML)
var node = {
namespaceURI: DOMNamespaces.svg,
@@ -38,9 +38,9 @@ var setInnerHTML = createMicrosoftUnsafeLocalFunction(
if (node.namespaceURI === DOMNamespaces.svg && !('innerHTML' in node)) {
reusableSVGContainer = reusableSVGContainer || document.createElement('div');
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
var newNodes = reusableSVGContainer.firstChild.childNodes;
for (var i = 0; i < newNodes.length; i++) {
node.appendChild(newNodes[i]);
var svgNode = reusableSVGContainer.firstChild;
while (svgNode.firstChild) {
node.appendChild(svgNode.firstChild);
}
} else {
node.innerHTML = html;