Skip to content

Commit

Permalink
upgrade jxon library (bugfix for modified Array.prototype)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrasd committed May 2, 2017
1 parent b1b5c40 commit ad56b38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "togpx",
"version": "0.5.3",
"version": "0.5.4",
"description": "convert geojson to gpx",
"main": "index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"concat-stream": "~1.0.1",
"jxon": "~2.0.0-beta.3",
"jxon": "~2.0.0-beta.5",
"optimist": "~0.3.5",
"xmldom": "~0.1.17"
},
Expand Down
13 changes: 7 additions & 6 deletions togpx.js
Expand Up @@ -229,7 +229,7 @@ module.exports = togpx;
// AMD. Register as an anonymous module.
define([], factory(window));
} else if (typeof exports === 'object') {
if (typeof window === 'object' && window.DOMImplementation) {
if (typeof window === 'object' && window.DOMImplementation && window.XMLSerializer && window.DOMParser) {
// Browserify. hardcode usage of browser's own XMLDom implementation
// see https://github.com/tyrasd/jxon/issues/18

Expand Down Expand Up @@ -432,7 +432,10 @@ module.exports = togpx;
for (var sName in oParentObj) {

vValue = oParentObj[sName];
if (vValue === null) {
if ( vValue === undefined ) {
continue;
}
if ( vValue === null ) {
vValue = {};
}

Expand All @@ -459,6 +462,7 @@ module.exports = togpx;
oParentEl.setAttribute(sName.slice(1), vValue);
} else if (vValue.constructor === Array) {
for (var nItem in vValue) {
if (!vValue.hasOwnProperty(nItem)) continue;
elementNS = (vValue[nItem] && vValue[nItem][opts.attrPrefix + 'xmlns']) || oParentEl.namespaceURI;
if (elementNS) {
oChild = oXMLDoc.createElementNS(elementNS, sName);
Expand All @@ -478,11 +482,8 @@ module.exports = togpx;
}
if (vValue instanceof Object) {
loadObjTree(oXMLDoc, oChild, vValue);
} else if (vValue !== null && vValue !== true) {
} else if (vValue !== null && (vValue !== true || !opts.trueIsEmpty)) {
oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
} else if (!opts.trueIsEmpty && vValue === true) {
oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));

}
oParentEl.appendChild(oChild);
}
Expand Down

0 comments on commit ad56b38

Please sign in to comment.