From 0986f03778578dc09de1128cec4dbcb06d4988ee Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Sun, 22 Jul 2018 21:36:02 +0300 Subject: Add global reference to support 'window' in bundlers - fixes #767 --- src/svg.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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) -- cgit v1.2.3