aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPerry Mitchell <perrymitchell@live.com>2018-07-22 21:36:02 +0300
committerGitHub <noreply@github.com>2018-07-22 21:36:02 +0300
commit0986f03778578dc09de1128cec4dbcb06d4988ee (patch)
tree119619b1a9acb7bb7562513085c3d0e35664199f /src
parenta180a4e4fd4d47f7a45db0d3fb66d3df4bfb6749 (diff)
downloadsvg.js-0986f03778578dc09de1128cec4dbcb06d4988ee.tar.gz
svg.js-0986f03778578dc09de1128cec4dbcb06d4988ee.zip
Add global reference to support 'window' in bundlers - fixes #767
Diffstat (limited to 'src')
-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..b28bef6 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)