Move logic from dom to xml module

This commit is contained in:
Björn Harrtell
2020-01-05 13:12:27 +01:00
parent 5b661ed84c
commit 05a5f162d4
3 changed files with 26 additions and 27 deletions
-24
View File
@@ -122,27 +122,3 @@ export function replaceChildren(node, children) {
node.insertBefore(newChild, oldChild); node.insertBefore(newChild, oldChild);
} }
} }
let document_ = undefined;
/**
* Register a Document to use when creating nodes for XML serializations. Can be used
* to inject a Document where there is no globally available implementation.
*
* @param {Document} document A Document.
* @api
*/
export function registerDocument(document) {
document_ = document;
}
/**
* Get a document that should be used when creating nodes for XML serializations.
* @return {Document} The document.
*/
export function getDocument() {
if (document_ === undefined && typeof document !== 'undefined') {
document_ = document.implementation.createDocument('', '', null);
}
return document_;
}
+1 -2
View File
@@ -1,8 +1,7 @@
/** /**
* @module ol/format/xsd * @module ol/format/xsd
*/ */
import {getDocument} from '../dom.js'; import {getAllTextContent, getDocument} from '../xml.js';
import {getAllTextContent} from '../xml.js';
import {padNumber} from '../string.js'; import {padNumber} from '../string.js';
+25 -1
View File
@@ -2,7 +2,6 @@
* @module ol/xml * @module ol/xml
*/ */
import {extend} from './array.js'; import {extend} from './array.js';
import {getDocument} from './dom.js';
/** /**
@@ -509,3 +508,28 @@ export function getXMLSerializer() {
} }
return xmlSerializer_; return xmlSerializer_;
} }
let document_ = undefined;
/**
* Register a Document to use when creating nodes for XML serializations. Can be used
* to inject a Document where there is no globally available implementation.
*
* @param {Document} document A Document.
* @api
*/
export function registerDocument(document) {
document_ = document;
}
/**
* Get a document that should be used when creating nodes for XML serializations.
* @return {Document} The document.
*/
export function getDocument() {
if (document_ === undefined && typeof document !== 'undefined') {
document_ = document.implementation.createDocument('', '', null);
}
return document_;
}