File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -483,6 +483,19 @@ describe("XMLBuilder", function() {
483483 expect ( result ) . toEqual ( expected ) ;
484484 } ) ;
485485
486+ it ( "should correctly handle values with oneListGroup" , function ( ) {
487+ const jObj = {
488+ "a" : [
489+ "(first)" ,
490+ "(second)"
491+ ] ,
492+ } ;
493+ const builder = new XMLBuilder ( { oneListGroup :"true" , attributesGroupName : "@" } ) ;
494+ const result = builder . build ( jObj ) ;
495+ const expected = `<a>(first)(second)</a>` ;
496+ expect ( result ) . toEqual ( expected ) ;
497+ } ) ;
498+
486499 it ( "should handle attributes with oneListGroup" , function ( ) {
487500 const jObj = {
488501 "a" : [
@@ -506,7 +519,7 @@ describe("XMLBuilder", function() {
506519 const expected = `<a foo="bar" baz="foo" bar="baz"><b>1</b><b>2</b></a>` ;
507520 expect ( result ) . toEqual ( expected ) ;
508521 } ) ;
509-
522+
510523 it ( 'should build tag with only text node' , async ( ) => {
511524 const schema_obj = {
512525 field : {
Original file line number Diff line number Diff line change @@ -135,7 +135,13 @@ Builder.prototype.j2x = function(jObj, level) {
135135 listTagVal += this . processTextOrObjNode ( item , key , level )
136136 }
137137 } else {
138- listTagVal += this . buildTextValNode ( item , key , '' , level ) ;
138+ if ( this . options . oneListGroup ) {
139+ let textValue = this . options . tagValueProcessor ( key , item ) ;
140+ textValue = this . replaceEntitiesValue ( textValue ) ;
141+ listTagVal += textValue ;
142+ } else {
143+ listTagVal += this . buildTextValNode ( item , key , '' , level ) ;
144+ }
139145 }
140146 }
141147 if ( this . options . oneListGroup ) {
You can’t perform that action at this time.
0 commit comments