fast-xml-parser
Advanced tools
Comparing version 4.0.0-beta.4 to 4.0.0-beta.5
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library. | ||
** 4.0.0-beta.5 / 2021-12-04** | ||
* fix: when a tag with name "attributes" | ||
** 4.0.0-beta.4 / 2021-12-02** | ||
@@ -4,0 +7,0 @@ * Support HTML document parsing |
{ | ||
"name": "fast-xml-parser", | ||
"version": "4.0.0-beta.4", | ||
"version": "4.0.0-beta.5", | ||
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries", | ||
@@ -5,0 +5,0 @@ "main": "./src/fxp.js", |
@@ -43,3 +43,3 @@ const {EOL} = require('os'); | ||
} | ||
const attStr = attr_to_str(tagObj.attributes, options); | ||
const attStr = attr_to_str(tagObj[":@"], options); | ||
let tagStart = indentation + `<${tagName}${attStr}`; | ||
@@ -66,3 +66,3 @@ let tagValue = arrToStr(tagObj[tagName], options, newJPath, level + 1); | ||
const key = keys[i]; | ||
if(key !== "attributes") return key; | ||
if(key !== ":@") return key; | ||
} | ||
@@ -69,0 +69,0 @@ } |
@@ -40,4 +40,4 @@ 'use strict'; | ||
if(tagObj.attributes){ | ||
assignAttributes( val, tagObj.attributes, newJpath, options); | ||
if(tagObj[":@"]){ | ||
assignAttributes( val, tagObj[":@"], newJpath, options); | ||
}else if(Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode){ | ||
@@ -78,3 +78,3 @@ val = val[options.textNodeName]; | ||
const key = keys[i]; | ||
if(key !== "attributes") return key; | ||
if(key !== ":@") return key; | ||
} | ||
@@ -81,0 +81,0 @@ } |
@@ -199,3 +199,3 @@ 'use strict'; | ||
,false | ||
, currentNode.attributes ? Object.keys(currentNode.attributes).length !== 0 : false | ||
, currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false | ||
, Object.keys(currentNode.child).length === 0); | ||
@@ -224,3 +224,3 @@ if(textData !== undefined && textData !== "") currentNode.add(this.options.textNodeName, textData); | ||
,false | ||
, currentNode.attributes ? Object.keys(currentNode.attributes).length !== 0 : false | ||
, currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false | ||
, Object.keys(currentNode.child).length === 0); | ||
@@ -247,3 +247,3 @@ | ||
,false | ||
, currentNode.attributes ? Object.keys(currentNode.attributes).length !== 0 : false | ||
, currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false | ||
, Object.keys(currentNode.child).length === 0); | ||
@@ -283,3 +283,3 @@ | ||
, false | ||
, currentNode.attributes ? Object.keys(currentNode.attributes).length !== 0 : false | ||
, currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false | ||
, false); | ||
@@ -318,3 +318,3 @@ if(textData !== undefined && textData !== "") currentNode.add(this.options.textNodeName, textData); | ||
if(tagName !== tagExp && attrExpPresent){ | ||
childNode.attributes = this.buildAttributesMap(tagExp, jPath); | ||
childNode[":@"] = this.buildAttributesMap(tagExp, jPath); | ||
} | ||
@@ -338,3 +338,3 @@ jPath = jPath.substr(0, jPath.lastIndexOf(".")); | ||
if(tagName !== tagExp && attrExpPresent){ | ||
childNode.attributes = this.buildAttributesMap(tagExp, jPath); | ||
childNode[":@"] = this.buildAttributesMap(tagExp, jPath); | ||
} | ||
@@ -350,3 +350,3 @@ jPath = jPath.substr(0, jPath.lastIndexOf(".")); | ||
if(tagName !== tagExp && attrExpPresent){ | ||
childNode.attributes = this.buildAttributesMap(tagExp, jPath); | ||
childNode[":@"] = this.buildAttributesMap(tagExp, jPath); | ||
} | ||
@@ -353,0 +353,0 @@ currentNode.addChild(childNode); |
@@ -7,3 +7,3 @@ 'use strict'; | ||
this.child = []; //nested tags, text, cdata, comments in order | ||
this.attributes = {}; //attributes map | ||
this[":@"] = {}; //attributes map | ||
} | ||
@@ -15,4 +15,4 @@ add(key,val){ | ||
addChild(node) { | ||
if(node.attributes && Object.keys(node.attributes).length > 0){ | ||
this.child.push( { [node.tagname]: node.child, attributes: node.attributes }); | ||
if(node[":@"] && Object.keys(node[":@"]).length > 0){ | ||
this.child.push( { [node.tagname]: node.child, [":@"]: node[":@"] }); | ||
}else{ | ||
@@ -19,0 +19,0 @@ this.child.push( { [node.tagname]: node.child }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90897