diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-11 17:37:06 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-11 17:37:06 +0100 |
commit | bf7703f5915c6154937f3febf812aad6483bff45 (patch) | |
tree | 384be2f9fff05e755669b14f2f8fa0a624dacf45 | |
parent | f2513baf3c9262190ee2c92fb98b2dd099bfbab2 (diff) | |
download | svg.js-bf7703f5915c6154937f3febf812aad6483bff45.tar.gz svg.js-bf7703f5915c6154937f3febf812aad6483bff45.zip |
make window and document exchangeable in case they are not globals alreay, make sure that init functions are chaninable
-rw-r--r-- | dist/svg.js | 98 | ||||
-rw-r--r-- | package-lock.json | 6 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/animation/Animator.js | 3 | ||||
-rw-r--r-- | src/animation/Timeline.js | 2 | ||||
-rw-r--r-- | src/elements/Bare.js | 3 | ||||
-rw-r--r-- | src/elements/Doc.js | 3 | ||||
-rw-r--r-- | src/elements/Dom.js | 4 | ||||
-rw-r--r-- | src/elements/Element.js | 1 | ||||
-rw-r--r-- | src/elements/Image.js | 3 | ||||
-rw-r--r-- | src/elements/Shape.js | 1 | ||||
-rw-r--r-- | src/elements/Style.js | 1 | ||||
-rw-r--r-- | src/elements/Text.js | 3 | ||||
-rw-r--r-- | src/main.js | 1 | ||||
-rw-r--r-- | src/modules/core/event.js | 3 | ||||
-rw-r--r-- | src/modules/core/parser.js | 3 | ||||
-rw-r--r-- | src/modules/core/selector.js | 3 | ||||
-rw-r--r-- | src/modules/core/textable.js | 4 | ||||
-rw-r--r-- | src/types/Box.js | 5 | ||||
-rw-r--r-- | src/types/Color.js | 2 | ||||
-rw-r--r-- | src/types/Matrix.js | 2 | ||||
-rw-r--r-- | src/types/Morphable.js | 3 | ||||
-rw-r--r-- | src/types/Point.js | 2 | ||||
-rw-r--r-- | src/types/SVGArray.js | 1 | ||||
-rw-r--r-- | src/types/SVGNumber.js | 2 | ||||
-rw-r--r-- | src/utils/adopter.js | 3 | ||||
-rw-r--r-- | src/utils/window.js | 10 |
27 files changed, 140 insertions, 33 deletions
diff --git a/dist/svg.js b/dist/svg.js index bcaef61..2243698 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens <wout@mick-wout.com> * @license MIT * -* BUILT: Thu Nov 08 2018 19:44:36 GMT+0100 (GMT+01:00) +* BUILT: Sun Nov 11 2018 17:18:46 GMT+0100 (GMT+01:00) */; var SVG = (function () { 'use strict'; @@ -320,16 +320,27 @@ var SVG = (function () { var xlink = 'http://www.w3.org/1999/xlink'; var svgjs = 'http://svgjs.com/svgjs'; + var globals = { + window: window, + document: document + }; + function registerWindow(w) { + globals.window = w; + globals.document = w.document; + } + var Base = function Base() { _classCallCheck(this, Base); }; + var window$1 = globals.window, + document$1 = globals.document; var elements = {}; var root = Symbol('root'); // Method for element creation function makeNode(name) { // create element - return document.createElementNS(ns, name); + return document$1.createElementNS(ns, name); } function makeInstance(element) { if (element instanceof Base) return element; @@ -343,7 +354,7 @@ var SVG = (function () { } if (typeof element === 'string' && element.charAt(0) !== '<') { - return adopt(document.querySelector(element)); + return adopt(document$1.querySelector(element)); } var node = makeNode('svg'); @@ -354,7 +365,7 @@ var SVG = (function () { return element; } function nodeOrNew(name, node) { - return node instanceof window.Node ? node : makeNode(name); + return node instanceof window$1.Node ? node : makeNode(name); } // Adopt existing svg elements function adopt(node) { @@ -363,7 +374,7 @@ var SVG = (function () { if (node.instance instanceof Base) return node.instance; - if (!(node instanceof window.SVGElement)) { + if (!(node instanceof window$1.SVGElement)) { return new elements.HtmlNode(node); } // initialize variables @@ -836,6 +847,7 @@ var SVG = (function () { memory: memory }); + var window$2 = globals.window; var listenerId = 0; function getEvents(node) { @@ -941,10 +953,10 @@ var SVG = (function () { function dispatch(node, event, data) { var n = getEventTarget(node); // Dispatch event - if (event instanceof window.Event) { + if (event instanceof window$2.Event) { n.dispatchEvent(event); } else { - event = new window.CustomEvent(event, { + event = new window$2.CustomEvent(event, { detail: data, cancelable: true }); @@ -1445,6 +1457,9 @@ var SVG = (function () { return this; } + var window$3 = globals.window, + document$2 = globals.document; + var Dom = /*#__PURE__*/ function (_EventTarget) { @@ -1609,7 +1624,8 @@ var SVG = (function () { parent = adopt(parent.node.parentNode); if (!type) return parent; // loop trough ancestors if type is given - while (parent && parent.node instanceof window.SVGElement) { + while (parent && parent.node instanceof window$3.SVGElement) { + // FIXME: That shouldnt be neccessary if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent; parent = adopt(parent.node.parentNode); } @@ -1730,8 +1746,8 @@ var SVG = (function () { outerHTML = outerHTML == null ? false : outerHTML; // Create temporary holder - well = document.createElementNS(ns, 'svg'); - fragment = document.createDocumentFragment(); // Dump raw svg + well = document$2.createElementNS(ns, 'svg'); + fragment = document$2.createDocumentFragment(); // Dump raw svg well.innerHTML = svgOrFn; // Transplant nodes into the fragment @@ -1759,6 +1775,7 @@ var SVG = (function () { extend(Dom, { attr: attr }); + register(Dom); var Doc = getClass(root); @@ -1914,6 +1931,7 @@ var SVG = (function () { return Element; }(Dom); + register(Element); var Container = /*#__PURE__*/ @@ -1951,6 +1969,7 @@ var SVG = (function () { return Container; }(Element); + register(Container); var Defs = /*#__PURE__*/ @@ -1979,6 +1998,8 @@ var SVG = (function () { }(Container); register(Defs); + var window$4 = globals.window; + var Doc$1 = /*#__PURE__*/ function (_Container) { @@ -1999,7 +2020,7 @@ var SVG = (function () { _createClass(Doc, [{ key: "isRoot", value: function isRoot() { - return !this.node.parentNode || !(this.node.parentNode instanceof window.SVGElement) || this.node.parentNode.nodeName === '#document'; + return !this.node.parentNode || !(this.node.parentNode instanceof window$4.SVGElement) || this.node.parentNode.nodeName === '#document'; } // Check if this is a root svg // If not, call docs from this element @@ -2060,6 +2081,7 @@ var SVG = (function () { }); register(Doc$1, 'Doc', true); + var document$3 = globals.document; function parser() { // Reuse cached element if possible if (!parser.nodes) { @@ -2073,7 +2095,7 @@ var SVG = (function () { } if (!parser.nodes.svg.node.parentNode) { - var b = document.body || document.documentElement; + var b = document$3.body || document$3.documentElement; parser.nodes.svg.addTo(b); } @@ -3129,11 +3151,12 @@ var SVG = (function () { return Queue; }(); + var window$5 = globals.window; var Animator = { nextDraw: null, frames: new Queue(), timeouts: new Queue(), - timer: window.performance || window.Date, + timer: window$5.performance || window$5.Date, transforms: [], frame: function frame(fn) { // Store the node @@ -3142,7 +3165,7 @@ var SVG = (function () { }); // Request an animation frame if we don't have one if (Animator.nextDraw === null) { - Animator.nextDraw = window.requestAnimationFrame(Animator._draw); + Animator.nextDraw = window$5.requestAnimationFrame(Animator._draw); } // Return the node so we can remove it easily @@ -3162,7 +3185,7 @@ var SVG = (function () { }); // Request another animation frame if we need one if (Animator.nextDraw === null) { - Animator.nextDraw = window.requestAnimationFrame(Animator._draw); + Animator.nextDraw = window$5.requestAnimationFrame(Animator._draw); } return node; @@ -3203,23 +3226,26 @@ var SVG = (function () { el(); }); // If we have remaining timeouts or frames, draw until we don't anymore - Animator.nextDraw = Animator.timeouts.first() || Animator.frames.first() ? window.requestAnimationFrame(Animator._draw) : null; + Animator.nextDraw = Animator.timeouts.first() || Animator.frames.first() ? window$5.requestAnimationFrame(Animator._draw) : null; } }; + var window$6 = globals.window, + document$4 = globals.document; + function isNulledBox(box) { return !box.w && !box.h && !box.x && !box.y; } function domContains(node) { - return (document.documentElement.contains || function (node) { + return (document$4.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); + return node === document$4; + }).call(document$4.documentElement, node); } var Box = @@ -3245,6 +3271,7 @@ var SVG = (function () { this.y2 = this.y + this.h; this.cx = this.x + this.w / 2; this.cy = this.y + this.h / 2; + return this; } // Merge rect box with another, return a new instance }, { @@ -3277,8 +3304,8 @@ var SVG = (function () { key: "addOffset", value: function addOffset() { // offset by window scroll position, because getBoundingClientRect changes when window is scrolled - this.x += window.pageXOffset; - this.y += window.pageYOffset; + this.x += window$6.pageXOffset; + this.y += window$6.pageYOffset; return this; } }, { @@ -3908,7 +3935,9 @@ var SVG = (function () { }); } - var time = window.performance || Date; + var window$7 = globals.window, + document$5 = globals.document; + var time = window$7.performance || Date; var makeSchedule = function makeSchedule(runnerInfo) { var start = runnerInfo.start; @@ -3933,7 +3962,7 @@ var SVG = (function () { return time.now(); }; - this._dispatcher = document.createElement('div'); // Store the timing variables + this._dispatcher = document$5.createElement('div'); // Store the timing variables this._startTime = 0; this._speed = 1.0; // Play control variables control how the animation proceeds @@ -5356,6 +5385,7 @@ var SVG = (function () { return Shape; }(Element); + register(Shape); var Circle = /*#__PURE__*/ @@ -5477,8 +5507,9 @@ var SVG = (function () { }(Element); register(Stop); + var document$6 = globals.document; function baseFind(query, parent) { - return map((parent || document).querySelectorAll(query), function (node) { + return map((parent || document$6).querySelectorAll(query), function (node) { return adopt(node); }); } // Scoped find method @@ -5651,6 +5682,8 @@ var SVG = (function () { }); register(Pattern); + var window$8 = globals.window; + var Image = /*#__PURE__*/ function (_Shape) { @@ -5667,7 +5700,7 @@ var SVG = (function () { key: "load", value: function load(url, callback) { if (!url) return this; - var img = new window.Image(); + var img = new window$8.Image(); on(img, 'load', function (e) { var p = this.parent(Pattern); // ensure image size @@ -6217,7 +6250,8 @@ var SVG = (function () { }); register(Rect); - // Create plain text node + var document$7 = globals.document; // Create plain text node + function plain(text) { // clear if build mode is disabled if (this._build === false) { @@ -6225,7 +6259,7 @@ var SVG = (function () { } // create text node - this.node.appendChild(document.createTextNode(text)); + this.node.appendChild(document$7.createTextNode(text)); return this; } // Get length of text element @@ -6238,6 +6272,8 @@ var SVG = (function () { length: length }); + var window$9 = globals.window; + var Text = /*#__PURE__*/ function (_Shape) { @@ -6373,7 +6409,7 @@ var SVG = (function () { var blankLineOffset = 0; var leading = this.dom.leading; this.each(function () { - var fontSize = window.getComputedStyle(this.node).getPropertyValue('font-size'); + var fontSize = window$9.getComputedStyle(this.node).getPropertyValue('font-size'); var dy = leading * new SVGNumber(fontSize); if (this.dom.newLined) { @@ -6491,6 +6527,8 @@ var SVG = (function () { }); register(Tspan); + var document$8 = globals.document; + var Bare = /*#__PURE__*/ function (_Container) { @@ -6511,7 +6549,7 @@ var SVG = (function () { } // create text node - this.node.appendChild(document.createTextNode(text)); + this.node.appendChild(document$8.createTextNode(text)); return this; } }]); @@ -6785,6 +6823,7 @@ var SVG = (function () { return this.put(new Style()).font(name, src, params); }) }); + register(Style); var _Symbol = /*#__PURE__*/ @@ -6954,6 +6993,7 @@ var SVG = (function () { defaults: defaults, parser: parser, find: baseFind, + registerWindow: registerWindow, Animator: Animator, Controller: Controller, Ease: Ease, diff --git a/package-lock.json b/package-lock.json index 1a0ddf4..3ba3ab7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2919,6 +2919,12 @@ "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", "dev": true }, + "esm": { + "version": "3.0.84", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.0.84.tgz", + "integrity": "sha512-SzSGoZc17S7P+12R9cg21Bdb7eybX25RnIeRZ80xZs+VZ3kdQKzqTp2k4hZJjR7p9l0186TTXSgrxzlMDBktlw==", + "dev": true + }, "espree": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/espree/-/espree-4.1.0.tgz", diff --git a/package.json b/package.json index 7adbde8..619b1f2 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.1", "eslint-plugin-standard": "^4.0.0", + "esm": "^3.0.84", "http-server": "^0.11.1", "jasmine-core": "^3.3.0", "karma": "^3.1.1", diff --git a/src/animation/Animator.js b/src/animation/Animator.js index fdb2326..4e0b112 100644 --- a/src/animation/Animator.js +++ b/src/animation/Animator.js @@ -1,5 +1,8 @@ +import globals from '../utils/window.js' import Queue from './Queue.js' +const { window } = globals + const Animator = { nextDraw: null, frames: new Queue(), diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js index 790033a..ff30a0d 100644 --- a/src/animation/Timeline.js +++ b/src/animation/Timeline.js @@ -1,6 +1,8 @@ import { registerMethods } from '../utils/methods.js' import Animator from './Animator.js' +import globals from '../utils/window.js' +const { window, document } = globals var time = window.performance || Date var makeSchedule = function (runnerInfo) { diff --git a/src/elements/Bare.js b/src/elements/Bare.js index 9415cd4..7162f3a 100644 --- a/src/elements/Bare.js +++ b/src/elements/Bare.js @@ -1,6 +1,9 @@ import { nodeOrNew, register, wrapWithAttrCheck } from '../utils/adopter.js' import { registerMethods } from '../utils/methods.js' import Container from './Container.js' +import globals from '../utils/window.js' + +const { document } = globals export default class Bare extends Container { constructor (node, attrs) { diff --git a/src/elements/Doc.js b/src/elements/Doc.js index 0d862ba..952f1d3 100644 --- a/src/elements/Doc.js +++ b/src/elements/Doc.js @@ -8,6 +8,9 @@ import { ns, svgjs, xlink, xmlns } from '../modules/core/namespaces.js' import { registerMethods } from '../utils/methods.js' import Container from './Container.js' import Defs from './Defs.js' +import globals from '../utils/window.js' + +const { window } = globals export default class Doc extends Container { constructor (node) { diff --git a/src/elements/Dom.js b/src/elements/Dom.js index 87d0f5e..8fa053c 100644 --- a/src/elements/Dom.js +++ b/src/elements/Dom.js @@ -8,9 +8,11 @@ import { } from '../utils/adopter.js' import { map } from '../utils/utils.js' import { ns } from '../modules/core/namespaces.js' +import globals from '../utils/window.js' import EventTarget from '../types/EventTarget.js' import attr from '../modules/core/attr.js' +const { window, document } = globals export default class Dom extends EventTarget { constructor (node, attrs) { @@ -154,7 +156,7 @@ export default class Dom extends EventTarget { if (!type) return parent // loop trough ancestors if type is given - while (parent && parent.node instanceof window.SVGElement) { + while (parent && parent.node instanceof window.SVGElement) { // FIXME: That shouldnt be neccessary if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent parent = adopt(parent.node.parentNode) } diff --git a/src/elements/Element.js b/src/elements/Element.js index 7d491f9..03b5f07 100644 --- a/src/elements/Element.js +++ b/src/elements/Element.js @@ -4,7 +4,6 @@ import { reference } from '../modules/core/regex.js' import Dom from './Dom.js' import SVGNumber from '../types/SVGNumber.js' - const Doc = getClass(root) export default class Element extends Dom { diff --git a/src/elements/Image.js b/src/elements/Image.js index c529439..6a01b8f 100644 --- a/src/elements/Image.js +++ b/src/elements/Image.js @@ -6,6 +6,9 @@ import { registerMethods } from '../utils/methods.js' import { xlink } from '../modules/core/namespaces.js' import Pattern from './Pattern.js' import Shape from './Shape.js' +import globals from '../utils/window.js' + +const { window } = globals export default class Image extends Shape { constructor (node) { diff --git a/src/elements/Shape.js b/src/elements/Shape.js index e2821fe..cdddc60 100644 --- a/src/elements/Shape.js +++ b/src/elements/Shape.js @@ -1,7 +1,6 @@ import { register } from '../utils/adopter.js' import Element from './Element.js' - export default class Shape extends Element {} register(Shape) diff --git a/src/elements/Style.js b/src/elements/Style.js index 1883184..50ec50e 100644 --- a/src/elements/Style.js +++ b/src/elements/Style.js @@ -3,7 +3,6 @@ import { registerMethods } from '../utils/methods.js' import { unCamelCase } from '../utils/utils.js' import Element from './Element.js' - function cssRule (selector, rule) { if (!selector) return '' if (!rule) return selector diff --git a/src/elements/Text.js b/src/elements/Text.js index b4ba0ad..41be916 100644 --- a/src/elements/Text.js +++ b/src/elements/Text.js @@ -9,8 +9,11 @@ import { attrs } from '../modules/core/defaults.js' import { registerMethods } from '../utils/methods.js' import SVGNumber from '../types/SVGNumber.js' import Shape from './Shape.js' +import globals from '../utils/window.js' import * as textable from '../modules/core/textable.js' +const { window } = globals + export default class Text extends Shape { // Initialize node constructor (node) { diff --git a/src/main.js b/src/main.js index 8a7fd96..1961604 100644 --- a/src/main.js +++ b/src/main.js @@ -61,6 +61,7 @@ export { default as parser } from './modules/core/parser.js' export { default as find } from './modules/core/selector.js' export * from './modules/core/event.js' export * from './utils/adopter.js' +export { registerWindow } from './utils/window.js' /* Animation Modules */ export { default as Animator } from './animation/Animator.js' diff --git a/src/modules/core/event.js b/src/modules/core/event.js index 2fcaf58..351fe3f 100644 --- a/src/modules/core/event.js +++ b/src/modules/core/event.js @@ -1,5 +1,8 @@ import { delimiter } from './regex.js' import { makeInstance } from '../../utils/adopter.js' +import globals from '../../utils/window.js' + +const { window } = globals let listenerId = 0 diff --git a/src/modules/core/parser.js b/src/modules/core/parser.js index 7a656ef..a490576 100644 --- a/src/modules/core/parser.js +++ b/src/modules/core/parser.js @@ -1,4 +1,7 @@ import Doc from '../../elements/Doc.js' +import globals from '../../utils/window.js' + +const { document } = globals export default function parser () { // Reuse cached element if possible diff --git a/src/modules/core/selector.js b/src/modules/core/selector.js index 1e0b55e..52a7ad1 100644 --- a/src/modules/core/selector.js +++ b/src/modules/core/selector.js @@ -1,6 +1,9 @@ import { adopt } from '../../utils/adopter.js' import { map } from '../../utils/utils.js' import { registerMethods } from '../../utils/methods.js' +import globals from '../../utils/window.js' + +const { document } = globals export default function baseFind (query, parent) { return map((parent || document).querySelectorAll(query), function (node) { diff --git a/src/modules/core/textable.js b/src/modules/core/textable.js index 139d056..cf452c6 100644 --- a/src/modules/core/textable.js +++ b/src/modules/core/textable.js @@ -1,3 +1,7 @@ +import globals from '../../utils/window.js' + +const { document } = globals + // Create plain text node export function plain (text) { // clear if build mode is disabled diff --git a/src/types/Box.js b/src/types/Box.js index 21672b1..97ba699 100644 --- a/src/types/Box.js +++ b/src/types/Box.js @@ -1,8 +1,11 @@ import { delimiter } from '../modules/core/regex.js' import { registerMethods } from '../utils/methods.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 } @@ -41,6 +44,8 @@ export default class Box { this.y2 = this.y + this.h this.cx = this.x + this.w / 2 this.cy = this.y + this.h / 2 + + return this } // Merge rect box with another, return a new instance diff --git a/src/types/Color.js b/src/types/Color.js index 6bbfd82..a96958b 100644 --- a/src/types/Color.js +++ b/src/types/Color.js @@ -93,6 +93,8 @@ export default class Color { this.g = g this.b = b } + + return this } // Default to hex conversion diff --git a/src/types/Matrix.js b/src/types/Matrix.js index 963fd1a..ee12488 100644 --- a/src/types/Matrix.js +++ b/src/types/Matrix.js @@ -37,6 +37,8 @@ export default class Matrix { this.d = source.d != null ? source.d : base.d this.e = source.e != null ? source.e : base.e this.f = source.f != null ? source.f : base.f + + return this } // Clones this matrix diff --git a/src/types/Morphable.js b/src/types/Morphable.js index 021c5f4..703cc00 100644 --- a/src/types/Morphable.js +++ b/src/types/Morphable.js @@ -121,6 +121,7 @@ export class NonMorphable { init (val) { val = Array.isArray(val) ? val[0] : val this.value = val + return this } valueOf () { @@ -152,6 +153,7 @@ export class TransformBag { } Object.assign(this, TransformBag.defaults, obj) + return this } toArray () { @@ -199,6 +201,7 @@ export class ObjectBag { }) this.values = entries.reduce((last, curr) => last.concat(curr), []) + return this } valueOf () { diff --git a/src/types/Point.js b/src/types/Point.js index 685240b..6a2b968 100644 --- a/src/types/Point.js +++ b/src/types/Point.js @@ -19,6 +19,8 @@ export default class Point { // merge source this.x = source.x == null ? base.x : source.x this.y = source.y == null ? base.y : source.y + + return this } // Clone point diff --git a/src/types/SVGArray.js b/src/types/SVGArray.js index 3894b22..4fcb500 100644 --- a/src/types/SVGArray.js +++ b/src/types/SVGArray.js @@ -12,6 +12,7 @@ extend(SVGArray, { init (arr) { this.length = 0 this.push(...this.parse(arr)) + return this }, toArray () { diff --git a/src/types/SVGNumber.js b/src/types/SVGNumber.js index bba9741..ea21cbd 100644 --- a/src/types/SVGNumber.js +++ b/src/types/SVGNumber.js @@ -40,6 +40,8 @@ export default class SVGNumber { this.unit = value.unit } } + + return this } toString () { diff --git a/src/utils/adopter.js b/src/utils/adopter.js index 88cd383..5d5d1f0 100644 --- a/src/utils/adopter.js +++ b/src/utils/adopter.js @@ -1,7 +1,10 @@ import { capitalize } from './utils.js' import { ns } from '../modules/core/namespaces.js' +import globals from '../utils/window.js' import Base from '../types/Base.js' +const { window, document } = globals + const elements = {} export const root = Symbol('root') diff --git a/src/utils/window.js b/src/utils/window.js new file mode 100644 index 0000000..f44ebb9 --- /dev/null +++ b/src/utils/window.js @@ -0,0 +1,10 @@ +const globals = { + window, document +} + +export default globals + +export function registerWindow (w) { + globals.window = w + globals.document = w.document +} |