Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,8 @@ 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 @@ -247,21 +236,21 @@ class SvgUri extends Component{
return null;
}

const textValue = node.nodeValue;
if (textValue) {
return textValue;
}

// Process the xml node
const arrayElements = [];

// if have children process them.
// Recursive function.
if (node.childNodes && node.childNodes.length > 0){
for (let i = 0; i < node.childNodes.length; i++){
const isTextValue = node.childNodes[i].nodeValue
if (isTextValue) {
arrayElements.push(node.childNodes[i].nodeValue)
} else {
const nodo = this.inspectNode(node.childNodes[i]);
if (nodo != null) {
arrayElements.push(nodo);
}
const nodo = this.inspectNode(node.childNodes[i]);
if (nodo != null) {
arrayElements.push(nodo);
}
}
}
Expand Down