Skip to content

Commit

Permalink
util.removeEmptyDivElements() removes nested <div>
Browse files Browse the repository at this point in the history
  • Loading branch information
dteviot committed Sep 29, 2016
1 parent cfc4123 commit 45f5eb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin/js/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var util = (function () {

// discard empty divs created when moving elements
var removeEmptyDivElements = function(element) {
util.removeElements(util.getElements(element, "div", e => util.isStringWhiteSpace(e.innerHTML)));
util.removeElements(util.getElements(element, "div", e => util.isElementWhiteSpace(e)));
}

var removeTrailingWhiteSpace = function(element) {
Expand Down
5 changes: 3 additions & 2 deletions unitTest/UtestUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ test("removeEmptyDivElements", function (assert) {
"<div><h1>H1</h1></div>" +
"<div><div></div></div>" +
"<div> \n\n\n</div>" +
"<div><img src=\"http://dumy.com/img.jpg\"></div>" +
"</body>" +
"</html>",
"text/html");
let content = dom.body.cloneNode(true);
let content = dom.body;
util.removeEmptyDivElements(content);

assert.equal(content.innerHTML, "<div><h1>H1</h1></div><div></div>");
assert.equal(content.innerHTML, "<div><h1>H1</h1></div><div><img src=\"http://dumy.com/img.jpg\"></div>");
});

test("removeScriptableElements", function (assert) {
Expand Down

0 comments on commit 45f5eb9

Please sign in to comment.