Skip to content

Commit 1c3faf8

Browse files
committed
j2x: Remove extra empty line before closing tag
1 parent 4ab773c commit 1c3faf8

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

spec/j2x_spec.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe("XMLParser", function () {
272272
});
273273

274274

275-
/* it("should format when parsing to XML", function () {
275+
it("should format when parsing to XML", function () {
276276
var jObj = {
277277
a : {
278278
"@": {
@@ -298,16 +298,14 @@ describe("XMLParser", function () {
298298
});
299299
var result = parser.parse(jObj);
300300
var expected = '<a b="val&gt;1" c="val&lt;2">\n'
301-
+'\t<tag>\n'
302-
+'\t\t<k>34</k>\n'
303-
+'\t\t<g>35 g&gt;</g>\n'
304-
+'\t\n'
305-
+'\t</tag>\n'
306-
+'text<![CDATA[this text is > from CDATA]]>value&gt;<![CDATA[this is another text]]>\n'
307-
+'</a>\n';
308-
console.log(result);
309-
console.log(expected);
301+
+' <tag>\n'
302+
+' <k>34</k>\n'
303+
+' <g>35 g&gt;</g>\n'
304+
+' </tag>\n'
305+
+'text<![CDATA[this text is > from CDATA]]>value&gt;<![CDATA[this is another text]]></a>\n';
306+
//console.log(result);
307+
//console.log(expected);
310308
expect(result).toEqual(expected);
311-
}); */
309+
});
312310

313311
});

src/j2x.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ Parser.prototype.j2x = function(jObj,level){
9292
}
9393
}else if(Array.isArray(jObj[key])){//repeated nodes
9494
if(this.isCDATA(key)){
95-
//check if textnode is present -> replace the value
96-
//else just add the value
97-
9895
if(jObj[this.options.textNodeName]){
9996
val += this.replaceCDATAarr(jObj[this.options.textNodeName], jObj[key]);
10097
}else{
@@ -109,7 +106,6 @@ Parser.prototype.j2x = function(jObj,level){
109106
val += this.buildObjNode(result.val,key,result.attrStr,level);
110107
}else{
111108
val += this.buildTextNode(item,key,"",level);
112-
//val += this.indentate(level) + "<"+key+">"+ this.encodeHTMLchar(item) + "</"+key+this.tagEndChar;
113109
}
114110
}
115111
}
@@ -156,7 +152,7 @@ function buildObjectNode(val,key,attrStr,level){
156152
+ "<" + key + attrStr
157153
+ this.tagEndChar
158154
+ val
159-
+ this.newLine
155+
//+ this.newLine
160156
+ this.indentate(level)
161157
+ "</"+key+this.tagEndChar;
162158
}

0 commit comments

Comments
 (0)