Эх сурвалжийг харах

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

Book Pauk 2 жил өмнө
parent
commit
772ea3ca0c

+ 4 - 2
server/core/xml/XmlParser.js

@@ -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}`);
                     }
                 }
             }