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/types | |
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/types')
-rw-r--r-- | src/types/Box.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/types/Box.js b/src/types/Box.js index 97ba699..8c1c4ca 100644 --- a/src/types/Box.js +++ b/src/types/Box.js @@ -1,23 +1,21 @@ import { delimiter } from '../modules/core/regex.js' import { registerMethods } from '../utils/methods.js' -import globals from '../utils/window.js' +import { globals } from '../utils/window.js' import Point from './Point.js' import parser from '../modules/core/parser.js' -const { window, document } = globals - function isNulledBox (box) { return !box.w && !box.h && !box.x && !box.y } function domContains (node) { - return (document.documentElement.contains || function (node) { + return (globals.document.documentElement.contains || function (node) { // This is IE - it does not support contains() for top-level SVGs while (node.parentNode) { node = node.parentNode } return node === document - }).call(document.documentElement, node) + }).call(globals.document.documentElement, node) } export default class Box { @@ -88,8 +86,8 @@ export default class Box { addOffset () { // offset by window scroll position, because getBoundingClientRect changes when window is scrolled - this.x += window.pageXOffset - this.y += window.pageYOffset + this.x += globals.window.pageXOffset + this.y += globals.window.pageYOffset return this } @@ -121,7 +119,7 @@ function getBox (cb) { box = cb(clone.node) clone.remove() } catch (e) { - console.warn('Getting a bounding box of this element is not possible') + throw new Error('Getting a bounding box of element "' + this.node.nodeName + '" is not possible') } } return box |