Skip to content

Commit

Permalink
Merge pull request #76 from adamski/master
Browse files Browse the repository at this point in the history
Remove empty strings from element children
  • Loading branch information
matc4 authored Sep 7, 2017
2 parents dd009ac + 0350c45 commit 9ef6404
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,19 @@ class SvgUri extends Component{

return responseXML;
}

// Remove empty strings from children array
trimElementChilden(children) {
for (child of children) {
if (typeof child === 'string') {
if (child.trim.length === 0)
children.splice(children.indexOf(child), 1);
}
}
}

createSVGElement(node, childs){
this.trimElementChilden(childs);
let componentAtts = {};
const i = ind++;
switch (node.nodeName) {
Expand Down Expand Up @@ -244,7 +255,6 @@ class SvgUri extends Component{
for (let i = 0; i < node.childNodes.length; i++){
const isTextValue = node.childNodes[i].nodeValue
if (isTextValue) {
console.log(node)
arrayElements.push(node.childNodes[i].nodeValue)
} else {
const nodo = this.inspectNode(node.childNodes[i]);
Expand Down

0 comments on commit 9ef6404

Please sign in to comment.