Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Fix IE9 issue with innerHTML on plaintext elements
Browse files Browse the repository at this point in the history
Setting innerHTML on plaintext elements creates non Text children.
Check if the element is a plaintext elemend and if so use textContent
instead.
  • Loading branch information
arv committed Jan 23, 2014
1 parent 76028bf commit 9727272
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/wrappers/HTMLElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
}
}

// IE11 does not have MSIE in the user agent string.
var oldIe = /MSIE/.test(navigator.userAgent);

var OriginalHTMLElement = window.HTMLElement;

function HTMLElement(node) {
Expand All @@ -147,6 +150,17 @@
return getInnerHTML(this);
},
set innerHTML(value) {
// IE9 does not handle set innerHTML correctly on plaintextParents. It
// creates element children. For example
//
// scriptElement.innerHTML = '<a>test</a>'
//
// Creates a single HTMLAnchorElement child.
if (oldIe && plaintextParents[this.localName]) {
this.textContent = value;
return;
}

var removedNodes = snapshotNodeList(this.childNodes);

if (this.invalidateShadowRenderer())
Expand Down

0 comments on commit 9727272

Please sign in to comment.