Merge pull request #300 from Klowner/dev-browserify-support

Add Browserify / CommonJS support (dev branch rebased)
master
Dmitry Baranovskiy 2014-09-17 16:23:47 +10:00
commit c0b0b5805e
3 changed files with 12 additions and 6 deletions

View File

@ -9,6 +9,9 @@
}, },
"author": "Dmitry Baranovskiy", "author": "Dmitry Baranovskiy",
"license": "Apache License v2", "license": "Apache License v2",
"dependencies": {
"eve": "~0.4.2"
},
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.0", "grunt-contrib-uglify": "~0.2.0",
@ -16,7 +19,6 @@
"grunt-exec": "~0.4.2", "grunt-exec": "~0.4.2",
"mocha": "*", "mocha": "*",
"expect.js": "*", "expect.js": "*",
"eve": "~0.4.2",
"dr.js": "~0.1.0" "dr.js": "~0.1.0"
} }
} }

View File

@ -5,9 +5,13 @@
define(["eve"], function( eve ) { define(["eve"], function( eve ) {
return factory(glob, 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 { } else {
// Browser globals (glob is window) // Browser globals (glob is window)
// Snap adds itself to window // Snap adds itself to window
factory(glob, glob.eve); factory(glob, glob.eve);
} }
}(this, function (window, eve) { }(window || this, function (window, eve) {

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
var Snap = (function() { var Snap = (function(root) {
Snap.version = "0.3.0"; Snap.version = "0.3.0";
/*\ /*\
* Snap * Snap
@ -55,8 +55,8 @@ Snap.toString = function () {
}; };
Snap._ = {}; Snap._ = {};
var glob = { var glob = {
win: window, win: root.window,
doc: window.document doc: root.window.document
}; };
Snap._.glob = glob; Snap._.glob = glob;
var has = "hasOwnProperty", var has = "hasOwnProperty",
@ -1612,4 +1612,4 @@ Snap.plugin = function (f) {
}; };
glob.win.Snap = Snap; glob.win.Snap = Snap;
return Snap; return Snap;
}()); }(window || this));