aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-12 23:09:25 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-28 13:42:25 +0100
commit675847a99f1640c87df0a6187eeb34b90d903666 (patch)
tree78483c739c2b164cd6b098d952658d636e3be745 /src/utils
parentfa0461eeddf65a249e1a674305684ae756a69965 (diff)
downloadsvg.js-675847a99f1640c87df0a6187eeb34b90d903666.tar.gz
svg.js-675847a99f1640c87df0a6187eeb34b90d903666.zip
plumber differences between node and browser so that tests run on both
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/window.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/utils/window.js b/src/utils/window.js
index 9e51339..626fde3 100644
--- a/src/utils/window.js
+++ b/src/utils/window.js
@@ -7,3 +7,26 @@ export function registerWindow (win = null, doc = null) {
globals.window = win
globals.document = doc
}
+
+const save = {}
+
+export function saveWindow () {
+ save.window = globals.window
+ save.document = globals.document
+}
+
+export function restoreWindow () {
+ globals.window = save.window
+ globals.document = save.document
+}
+
+export function withWindow (win, fn) {
+ saveWindow()
+ registerWindow(win, win.document)
+ fn(win, win.document)
+ restoreWindow()
+}
+
+export function getWindow () {
+ return globals.window
+}