From bc7b84b162546e1523ab0d7a8d7e92156a7701c8 Mon Sep 17 00:00:00 2001 From: Sam Breed Date: Sun, 12 Jan 2014 19:43:55 -0700 Subject: [PATCH 1/3] adding CommonJS / Browserify support to amd banner --- src/amd-banner.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd-banner.js b/src/amd-banner.js index 6affb7f..94ed6c1 100644 --- a/src/amd-banner.js +++ b/src/amd-banner.js @@ -5,9 +5,13 @@ define(["eve"], function( eve ) { return factory(glob, eve); }); + } else if (typeof exports !== 'undefined') { + // Next for Node.js or CommonJS + var eve = require('eve'); + module.exports = factory(glob, eve); } else { // Browser globals (glob is window) // Snap adds itself to window factory(glob, glob.eve); } -}(this, function (window, eve) { \ No newline at end of file +}(window || this, function (window, eve) { From ae835b9f6334db804f883bb5140bcfcf5d843d73 Mon Sep 17 00:00:00 2001 From: Sam Breed Date: Sun, 12 Jan 2014 19:44:30 -0700 Subject: [PATCH 2/3] explicitly pass the global scope to the SVG iffe Conflicts: src/svg.js --- src/svg.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/svg.js b/src/svg.js index fc8b038..d1680b5 100644 --- a/src/svg.js +++ b/src/svg.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -var Snap = (function() { +var Snap = (function(root) { Snap.version = "0.3.0"; /*\ * Snap @@ -55,8 +55,8 @@ Snap.toString = function () { }; Snap._ = {}; var glob = { - win: window, - doc: window.document + win: root.window, + doc: root.window.document }; Snap._.glob = glob; var has = "hasOwnProperty", @@ -1612,4 +1612,4 @@ Snap.plugin = function (f) { }; glob.win.Snap = Snap; return Snap; -}()); +}(window || this)); From 22d755e3153b5f57002e730ba62eb2bd4ce0d651 Mon Sep 17 00:00:00 2001 From: Sam Breed Date: Sun, 12 Jan 2014 21:27:17 -0700 Subject: [PATCH 3/3] adding eve as a dependency and removing from devDependencies Conflicts: package.json --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index fb108c9..11bcec2 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ }, "author": "Dmitry Baranovskiy", "license": "Apache License v2", + "dependencies": { + "eve": "~0.4.2" + }, "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-uglify": "~0.2.0", @@ -16,7 +19,6 @@ "grunt-exec": "~0.4.2", "mocha": "*", "expect.js": "*", - "eve": "~0.4.2", "dr.js": "~0.1.0" } }