Skip to content

Commit bab0bfb

Browse files
author
William Reis Fernandes
committed
feat: upgrade packages and change function xml2str
1 parent a707577 commit bab0bfb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

test/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ function toDOM(_) {
5555
return new DOMParser().parseFromString(_, 'text/xml');
5656
}
5757
} catch (error) {
58-
throw new error;
58+
throw new Error(error.message);
5959
}
6060
}

togeojson.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ var toGeoJSON = (function () {
107107
function xml2str(xmlNode) {
108108
var serializer;
109109
try {
110+
if (typeof XMLSerializer !== 'undefined') {
110111
// Gecko- and Webkit-based browsers (Firefox, Chrome), Opera.
111-
return new XMLSerializer().serializeToString(xmlNode);
112+
return new XMLSerializer().serializeToString(xmlNode);
113+
}else if (xmlNode && xmlNode.outerHTML) {
114+
return xmlNode.outerHTML;
115+
}
112116
} catch (e) {
113117
try {
114118
var isNodeEnv = typeof process === 'object' && !process.browser;
@@ -122,7 +126,7 @@ var toGeoJSON = (function () {
122126
} catch (er) {
123127
//Other browsers without XML Serializer
124128
console.error(e);
125-
throw new er;
129+
throw new Error(er.message);
126130
}
127131
}
128132
}

0 commit comments

Comments
 (0)