Skip to content

Commit

Permalink
Test that setting innerText on <br> etc doesn't throw
Browse files Browse the repository at this point in the history
  • Loading branch information
zcorpan committed Aug 18, 2016
1 parent 41ac1ae commit 203878e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions innerText/setter-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ testHTML("<div><br>", "abc", "abc", "Existing <br> deleted");
testHTML("<div>", "", "", "Assigning the empty string");
testHTML("<div>", null, "", "Assigning null");
testHTML("<div>", undefined, "undefined", "Assigning undefined");

// Setting innerText on these should not throw
["area", "base", "basefont", "br", "col", "embed", "frame", "hr", "image",
"img", "input", "keygen", "link", "menuitem", "meta", "param", "source",
"track", "wbr", "colgroup", "frameset", "head", "html", "table", "tbody",
"tfoot", "thead", "tr"].forEach(function(tag) {
testText(document.createElement(tag), "abc", "abc", "innerText on <" + tag + "> element");
});
8 changes: 7 additions & 1 deletion innerText/setter.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
<div id="container"></div>
<script>
function setupTest(context, plain) {
container.innerHTML = context;
// context is either a string or an element node
if (typeof context === "string") {
container.innerHTML = context;
} else {
container.innerHTML = "";
container.appendChild(context);
}
var e = container.firstChild;
while (e && e.nodeType != Node.ELEMENT_NODE) {
e = e.nextSibling;
Expand Down

0 comments on commit 203878e

Please sign in to comment.