Fix/gpx export chrome (#131)
* fix duplicate xmlns attribute for Chrome-based browsers but add it back in for Firefox * remove log statement; improve comment * derive xml namespace from defaultAttributes
This commit is contained in:
@@ -8,7 +8,7 @@ import Waypoint from './waypoint';
|
|||||||
const defaultAttributes = {
|
const defaultAttributes = {
|
||||||
version: '1.1',
|
version: '1.1',
|
||||||
creator: 'wanderer',
|
creator: 'wanderer',
|
||||||
'xmlns:prod': 'http://www.topografix.com/GPX/1/1',
|
xmlns: 'http://www.topografix.com/GPX/1/1',
|
||||||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'xsi:schemaLocation':
|
'xsi:schemaLocation':
|
||||||
'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'
|
'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'
|
||||||
@@ -18,7 +18,7 @@ export default class GPX {
|
|||||||
$: {
|
$: {
|
||||||
version: string;
|
version: string;
|
||||||
creator: string;
|
creator: string;
|
||||||
'xmlns:prod': string;
|
xmlns: string;
|
||||||
'xmlns:xsi': string;
|
'xmlns:xsi': string;
|
||||||
'xsi:schemaLocation': string;
|
'xsi:schemaLocation': string;
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ export default class GPX {
|
|||||||
$?: {
|
$?: {
|
||||||
version: string,
|
version: string,
|
||||||
creator: string,
|
creator: string,
|
||||||
'xmlns:prod': string,
|
xmlns: string,
|
||||||
'xmlns:xsi': string,
|
'xmlns:xsi': string,
|
||||||
'xsi:schemaLocation': string,
|
'xsi:schemaLocation': string,
|
||||||
}
|
}
|
||||||
@@ -151,6 +151,13 @@ export default class GPX {
|
|||||||
const gpx = new GPX(this);
|
const gpx = new GPX(this);
|
||||||
allDatesToISOString(gpx);
|
allDatesToISOString(gpx);
|
||||||
|
|
||||||
return builder.buildObject(gpx).replace('xmlns:prod', 'xmlns');
|
let xmlString = builder.buildObject(gpx);
|
||||||
|
|
||||||
|
// Ensure xmlns is present in the root element for Firefox
|
||||||
|
if (!xmlString.includes(`xmlns="${defaultAttributes["xmlns"]}"`)) {
|
||||||
|
xmlString = xmlString.replace('<gpx', `<gpx xmlns="${defaultAttributes["xmlns"]}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return xmlString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user