Permalink
Browse files

return early if html is an empty string

  • Loading branch information...
DanFerrer committed Jan 9, 2019
1 parent 98bc65b commit 641b8980fd1ac593eee45bd57cf09b0335765f96
Showing with 10 additions and 0 deletions.
  1. +3 −0 src/js/utils/dom.js
  2. +7 −0 test/unit/replace-inner-html-test.js
@@ -17,6 +17,9 @@ export function replaceInnerHtml(element, html) {
}

function appendHtml(element, html) {
if (!html) {
return;
}
// Add parsed html and text nodes to another element
const fragment = document.createDocumentFragment();
const nodes = htmlToParentElement(html).childNodes;
@@ -34,4 +34,11 @@ describe('replaceInnerHtml', function () {
expect(console.log).to.have.callCount(0);
expect(element.firstChild).to.equal(null);
});

it('should not append if html is an empty string', function() {
const empty = '';
replaceInnerHtml(element, empty);
expect(element.firstChild).to.equal(null);
});

});

0 comments on commit 641b898

Please sign in to comment.