Comparing version 1.5.0 to 1.5.1
@@ -18,2 +18,3 @@ var common = require('./common'); | ||
common.ensureFlagExists('fullTagEmptyElement', options); | ||
common.ensureFlagExists('noQuotesForNativeAttributes', options); | ||
common.ensureSpacesExists(options); | ||
@@ -44,8 +45,9 @@ if (typeof options.spaces === 'number') { | ||
} | ||
var key, attr, result = ''; | ||
var key, attr, quote, result = ''; | ||
for (key in attributes) { | ||
if (attributes.hasOwnProperty(key)) { | ||
quote = options.noQuotesForNativeAttributes && typeof attributes[key] !== 'string' ? '' : '"'; | ||
attr = '' + attributes[key]; // ensure Number and Boolean are converted to String | ||
result += (options.spaces && options.indentAttributes? writeIndentation(options, depth+1, false) : ' ') | ||
result += key + '="' + attr.replace(/"/g, '"') + '"'; | ||
result += (options.spaces && options.indentAttributes? writeIndentation(options, depth+1, false) : ' '); | ||
result += key + '=' + quote + attr.replace(/"/g, '"') + quote; | ||
} | ||
@@ -201,5 +203,12 @@ } | ||
function writeElementCompact(element, name, options, depth, indent) { | ||
if (typeof element === 'undefined' || element === null) { | ||
return options.fullTagEmptyElement ? '<' + name + '></' + name + '>' : '<' + name + '/>'; | ||
} | ||
var xml = ''; | ||
if (name) { | ||
xml += '<' + name; | ||
if (typeof element !== 'object') { | ||
xml += '>' + writeText(element,options) + '</' + name + '>'; | ||
return xml; | ||
} | ||
if (element[options.attributesKey]) { | ||
@@ -206,0 +215,0 @@ xml += writeAttributes(element[options.attributesKey], options, depth); |
{ | ||
"name": "xml-js", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "A convertor between XML text and Javascript object / JSON text.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -66,2 +66,3 @@ export interface ElementCompact { | ||
fullTagEmptyElement?: boolean | ||
noQuotesForNativeAttributes?: boolean | ||
} | ||
@@ -68,0 +69,0 @@ |
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
68311
924