Поправлен баг в fromObject

This commit is contained in:
Book Pauk
2022-12-02 16:52:48 +07:00
parent 5c77b1711b
commit 772ea3ca0c

View File

@@ -734,8 +734,8 @@ class XmlParser extends NodeBase {
} else if (tag === '*ATTRS') {
//пропускаем
} else {
if (typeof(objNode) === 'string') {
result.push(this.createNode(tag, null, [this.createText(objNode).raw]).raw);
if (typeof(objNode) === 'string' || typeof(objNode) === 'number') {
result.push(this.createNode(tag, null, [this.createText(objNode.toString()).raw]).raw);
} else if (Array.isArray(objNode)) {
for (const n of objNode) {
if (typeof(n) === 'string') {
@@ -747,6 +747,8 @@ class XmlParser extends NodeBase {
} else if (typeof(objNode) === 'object') {
result.push(this.createNode(tag, (objNode['*ATTRS'] ? Object.entries(objNode['*ATTRS']) : null), objectToNodes(objNode)).raw);
} else {
throw new Error(`Unknown node type "${typeof(objNode)}" of node: ${objNode}`);
}
}
}