Skip to content

Commit

Permalink
Committed by npm script.
Browse files Browse the repository at this point in the history
  • Loading branch information
nashwaan committed Oct 3, 2017
1 parent ad921da commit 8ac5b7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 2 additions & 6 deletions lib/js2xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,10 @@ function hasContentCompact(element, options, anyContent) {
}

function writeElementCompact(element, name, options, depth, indent) {
var xml = '';
if (typeof element === 'undefined' || element === null) {
if (options.fullTagEmptyElement) {
return '<' + name + '></' + name + '>';
} else {
return '';
}
return options.fullTagEmptyElement ? '<' + name + '></' + name + '>' : '<' + name + '/>';
}
var xml = '';
if (name) {
xml += '<' + name;
if (typeof element !== 'object') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xml-js",
"version": "1.5.0",
"version": "1.5.1",
"description": "A convertor between XML text and Javascript object / JSON text.",
"repository": {
"type": "git",
Expand Down
19 changes: 18 additions & 1 deletion test/js2xml_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ describe('Testing js2xml.js:', function () {

});

fdescribe('case by kolis ', function () {
describe('case by kolis ', function () {
// see https://github.com/nashwaan/xml-js/issues/31
var js = {
parent: {
Expand Down Expand Up @@ -729,6 +729,23 @@ describe('Testing js2xml.js:', function () {

});

describe('case by techborn ', function () {
// see https://github.com/nashwaan/xml-js/pull/32
// var js = {
// example: {
// _text: 'value'
// }
// };
var js = {
example: 'value'
};
var xml = '<example>value</example>';
it('should convert element text without _text property', function () {
expect(convert.js2xml(js, {compact: true})).toEqual(xml);
});

});

});

});

0 comments on commit 8ac5b7c

Please sign in to comment.