diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-12 09:35:37 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-12 09:35:37 +0100 |
commit | d3f8d83551799db061a558537bc89dcbfd522c21 (patch) | |
tree | f6456de7ac3599c35b217c9f769cb1adca03997f /src/utils/adopter.js | |
parent | bf7703f5915c6154937f3febf812aad6483bff45 (diff) | |
download | svg.js-d3f8d83551799db061a558537bc89dcbfd522c21.tar.gz svg.js-d3f8d83551799db061a558537bc89dcbfd522c21.zip |
evaluate window and document on access and not on import
Diffstat (limited to 'src/utils/adopter.js')
-rw-r--r-- | src/utils/adopter.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/utils/adopter.js b/src/utils/adopter.js index 5d5d1f0..5de4038 100644 --- a/src/utils/adopter.js +++ b/src/utils/adopter.js @@ -1,17 +1,15 @@ import { capitalize } from './utils.js' import { ns } from '../modules/core/namespaces.js' -import globals from '../utils/window.js' +import { globals } from '../utils/window.js' import Base from '../types/Base.js' -const { window, document } = globals - const elements = {} export const root = Symbol('root') // Method for element creation export function makeNode (name) { // create element - return document.createElementNS(ns, name) + return globals.document.createElementNS(ns, name) } export function makeInstance (element) { @@ -26,7 +24,7 @@ export function makeInstance (element) { } if (typeof element === 'string' && element.charAt(0) !== '<') { - return adopt(document.querySelector(element)) + return adopt(globals.document.querySelector(element)) } var node = makeNode('svg') @@ -40,7 +38,7 @@ export function makeInstance (element) { } export function nodeOrNew (name, node) { - return node instanceof window.Node ? node : makeNode(name) + return node instanceof globals.window.Node ? node : makeNode(name) } // Adopt existing svg elements @@ -51,7 +49,7 @@ export function adopt (node) { // make sure a node isn't already adopted if (node.instance instanceof Base) return node.instance - if (!(node instanceof window.SVGElement)) { + if (!(node instanceof globals.window.SVGElement)) { return new elements.HtmlNode(node) } |