Skip to content

Commit

Permalink
Add explicit import of d3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jheer committed Apr 6, 2013
1 parent f67f868 commit 00d158e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
var globals = ["vg"],
// cache pre-existing global values
var globals = ["vg", "d3"],
globalValues = {};

globals.forEach(function(g) {
if (g in global) globalValues[g] = global[g];
});

// Namespace pollution!
// ensure availability of d3 in global namespace
// NOTE: will "pollute" namespace with jsdom window, etc
d3 = require("d3");

// load and export vega
require("./vega");
module.exports = vg;

// restore pre-existing global values
globals.forEach(function(g) {
if (g in globalValues) global[g] = globalValues[g];
else delete global[g];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vega",
"version": "1.1.0",
"version": "1.1.1",
"description": "Vega Runtime",
"keywords": [
"vega",
Expand Down
2 changes: 1 addition & 1 deletion src/_package.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var vg = {};

// semantic versioning
vg.version = '1.1.0';
vg.version = '1.1.1';

// type checking functions
var toString = Object.prototype.toString;
Expand Down
2 changes: 1 addition & 1 deletion src/core/_end.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
return vg;
})();
})(d3); // assumes availability of D3 in global namespace
2 changes: 1 addition & 1 deletion src/core/_start.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vg = (function(){
vg = (function(d3){ // take d3 instance as sole import
6 changes: 3 additions & 3 deletions vega.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vg = (function(){
vg = (function(d3){ // take d3 instance as sole import
var vg = {};

// semantic versioning
vg.version = '1.1.0';
vg.version = '1.1.1';

// type checking functions
var toString = Object.prototype.toString;
Expand Down Expand Up @@ -4141,4 +4141,4 @@ vg.spec = function(s) {
return new vg.Spec(s);
};
return vg;
})();
})(d3); // assumes availability of D3 in global namespace
4 changes: 2 additions & 2 deletions vega.min.js

Large diffs are not rendered by default.

0 comments on commit 00d158e

Please sign in to comment.