Rework to make DOMImplementation lazy and injectable

This commit is contained in:
Björn Harrtell
2019-11-06 22:24:05 +01:00
parent 6063021792
commit 90d61033e0
3 changed files with 38 additions and 16 deletions
+2 -10
View File
@@ -2,6 +2,7 @@
* @module ol/xml
*/
import {extend} from './array.js';
import {getDocument} from './dom.js';
/**
@@ -23,15 +24,6 @@ import {extend} from './array.js';
*/
/**
* This document should be used when creating nodes for XML serializations. This
* document is also used by {@link module:ol/xml~createElementNS}
* @const
* @type {Document}
*/
export const DOCUMENT = document.implementation.createDocument('', '', null);
/**
* @type {string}
*/
@@ -44,7 +36,7 @@ export const XML_SCHEMA_INSTANCE_URI = 'http://www.w3.org/2001/XMLSchema-instanc
* @return {Element} Node.
*/
export function createElementNS(namespaceURI, qualifiedName) {
return DOCUMENT.createElementNS(namespaceURI, qualifiedName);
return getDocument().createElementNS(namespaceURI, qualifiedName);
}