From 05a5f162d482d593adc1e3a687b85b1d23a249d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Sun, 5 Jan 2020 13:12:27 +0100 Subject: [PATCH] Move logic from dom to xml module --- src/ol/dom.js | 24 ------------------------ src/ol/format/xsd.js | 3 +-- src/ol/xml.js | 26 +++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/ol/dom.js b/src/ol/dom.js index bf3274686a..900fa6d559 100644 --- a/src/ol/dom.js +++ b/src/ol/dom.js @@ -122,27 +122,3 @@ export function replaceChildren(node, children) { 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_; -} diff --git a/src/ol/format/xsd.js b/src/ol/format/xsd.js index 0aeb2c5c01..271b590679 100644 --- a/src/ol/format/xsd.js +++ b/src/ol/format/xsd.js @@ -1,8 +1,7 @@ /** * @module ol/format/xsd */ -import {getDocument} from '../dom.js'; -import {getAllTextContent} from '../xml.js'; +import {getAllTextContent, getDocument} from '../xml.js'; import {padNumber} from '../string.js'; diff --git a/src/ol/xml.js b/src/ol/xml.js index 5d040a3ae1..276a9c4482 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -2,7 +2,6 @@ * @module ol/xml */ import {extend} from './array.js'; -import {getDocument} from './dom.js'; /** @@ -509,3 +508,28 @@ export function getXMLSerializer() { } 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_; +}