Skip to content

Commit

Permalink
strip empty text nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed May 1, 2017
1 parent 6709607 commit 19663e3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ function belCreateElement (tag, props, children) {
}

if (typeof node === 'string') {
if (/^[\S+\n\r\s]+$/.test(node)) continue
if (el.lastChild && el.lastChild.nodeName === '#text') {
el.lastChild.nodeValue += node
el.lastChild.nodeValue += node.trim()
continue
}
node = document.createTextNode(node)
node = document.createTextNode(node.trim())
}

if (node && node.nodeType) {
Expand Down

0 comments on commit 19663e3

Please sign in to comment.