Skip to content

Commit 512f3f9

Browse files
committed
chore: resolve codeclimate issues
1 parent 54a374a commit 512f3f9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/ignoreAttributes.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function (ignoreAttributes) {
1+
function getIgnoreAttributesFn(ignoreAttributes) {
22
if (typeof ignoreAttributes === 'function') {
33
return ignoreAttributes
44
}
@@ -15,4 +15,6 @@ module.exports = function (ignoreAttributes) {
1515
}
1616
}
1717
return () => false
18-
}
18+
}
19+
20+
module.exports = getIgnoreAttributesFn

src/xmlbuilder/json2xml.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ Builder.prototype.j2x = function(jObj, level, ajPath) {
103103
} else if (typeof jObj[key] !== 'object') {
104104
//premitive type
105105
const attr = this.isAttribute(key);
106-
if (attr) {
107-
if (!this.ignoreAttributesFn(attr, jPath)) {
108-
attrStr += this.buildAttrPairStr(attr, '' + jObj[key]);
109-
}
110-
}else {
106+
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
107+
attrStr += this.buildAttrPairStr(attr, '' + jObj[key]);
108+
} else if (!attr) {
111109
//tag value
112110
if (key === this.options.textNodeName) {
113111
let newval = this.options.tagValueProcessor(key, '' + jObj[key]);

0 commit comments

Comments
 (0)