summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-07-22 22:14:00 +0200
committerGitHub <noreply@github.com>2018-07-22 22:14:00 +0200
commit9a6dea2e5abdbf83b3f75d5dd3707eed0f690859 (patch)
tree731ae2a19a6dab3777d17fbbb3321a1b7e18b3a8
parenta180a4e4fd4d47f7a45db0d3fb66d3df4bfb6749 (diff)
parent66e3a8fe76cc920d34f35271138253a28c5fb22d (diff)
downloadsvg.js-9a6dea2e5abdbf83b3f75d5dd3707eed0f690859.tar.gz
svg.js-9a6dea2e5abdbf83b3f75d5dd3707eed0f690859.zip
Merge pull request #883 from perry-mitchell/patch-1
Add global reference to support 'window' in bundlers - fixes #767
-rw-r--r--src/svg.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/svg.js b/src/svg.js
index ee8832e..a0bd5fc 100644
--- a/src/svg.js
+++ b/src/svg.js
@@ -1,5 +1,9 @@
+// Find global reference - uses 'this' by default when available,
+// falls back to 'window' otherwise (for bundlers like Webpack)
+var globalRef = (typeof this !== "undefined") ? this : window;
+
// The main wrapping element
-var SVG = this.SVG = function(element) {
+var SVG = globalRef.SVG = function(element) {
if (SVG.supported) {
element = new SVG.Doc(element)