Skip to content
This repository
Browse code

Use captured references for document and window.

This avoids an inconsistency (discussed in #1044) when using D3 inside Node.js,
where D3 internally creates a JSDOM document during initialization, but then
subsequently depends on the current global document, which is not exposed. D3
now always refers to the global document at the time of initialization, and
does not depend on the current global document or window.
commit 0991f3b010860889bd4693ee3bbd7dcf4963e17b 1 parent 183060d
Mike Bostock authored January 31, 2013
2  Makefile
@@ -27,10 +27,10 @@ all: \
27 27
 	src/end.js
28 28
 
29 29
 d3.core.js: \
  30
+	src/core/core.js \
30 31
 	src/core/format-$(LOCALE).js \
31 32
 	src/compat/date.js \
32 33
 	src/compat/style.js \
33  
-	src/core/core.js \
34 34
 	src/core/class.js \
35 35
 	src/core/array.js \
36 36
 	src/core/map.js \
68  d3.js
... ...
@@ -1,26 +1,26 @@
1 1
 (function() {
  2
+  d3 = {
  3
+    version: "3.0.5"
  4
+  };
  5
+  var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π, d3_document = document, d3_window = window;
  6
+  function d3_target(d) {
  7
+    return d.target;
  8
+  }
  9
+  function d3_source(d) {
  10
+    return d.source;
  11
+  }
2 12
   var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ];
3 13
   if (!Date.now) Date.now = function() {
4 14
     return +new Date();
5 15
   };
6 16
   try {
7  
-    document.createElement("div").style.setProperty("opacity", 0, "");
  17
+    d3_document.createElement("div").style.setProperty("opacity", 0, "");
8 18
   } catch (error) {
9  
-    var d3_style_prototype = CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
  19
+    var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
10 20
     d3_style_prototype.setProperty = function(name, value, priority) {
11 21
       d3_style_setProperty.call(this, name, value + "", priority);
12 22
     };
13 23
   }
14  
-  d3 = {
15  
-    version: "3.0.5"
16  
-  };
17  
-  var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
18  
-  function d3_target(d) {
19  
-    return d.target;
20  
-  }
21  
-  function d3_source(d) {
22  
-    return d.source;
23  
-  }
24 24
   function d3_class(ctor, properties) {
25 25
     try {
26 26
       for (var key in properties) {
@@ -43,7 +43,7 @@
43 43
     return Array.prototype.slice.call(pseudoarray);
44 44
   }
45 45
   try {
46  
-    d3_array(document.documentElement.childNodes)[0].nodeType;
  46
+    d3_array(d3_document.documentElement.childNodes)[0].nodeType;
47 47
   } catch (e) {
48 48
     d3_array = d3_arrayCopy;
49 49
   }
@@ -395,7 +395,7 @@
395 395
     return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
396 396
   };
397 397
   d3.xhr = function(url, mimeType, callback) {
398  
-    var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
  398
+    var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
399 399
     "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
400 400
       request.readyState > 3 && respond();
401 401
     };
@@ -474,8 +474,8 @@
474 474
     return d3.xhr(url, "text/html", callback).response(d3_html);
475 475
   };
476 476
   function d3_html(request) {
477  
-    var range = document.createRange();
478  
-    range.selectNode(document.body);
  477
+    var range = d3_document.createRange();
  478
+    range.selectNode(d3_document.body);
479 479
     return range.createContextualFragment(request.responseText);
480 480
   }
481 481
   d3.xml = function() {
@@ -805,7 +805,7 @@
805 805
     return dispatch;
806 806
   }
807 807
   d3.transform = function(string) {
808  
-    var g = document.createElementNS(d3.ns.prefix.svg, "g");
  808
+    var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
809 809
     return (d3.transform = function(string) {
810 810
       g.setAttribute("transform", string);
811 811
       var t = g.transform.baseVal.consolidate();
@@ -1440,7 +1440,7 @@
1440 1440
     return n.querySelector(s);
1441 1441
   }, d3_selectAll = function(s, n) {
1442 1442
     return n.querySelectorAll(s);
1443  
-  }, d3_selectRoot = document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) {
  1443
+  }, d3_selectRoot = d3_document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) {
1444 1444
     return d3_selectMatcher.call(n, s);
1445 1445
   };
1446 1446
   if (typeof Sizzle === "function") {
@@ -1592,7 +1592,7 @@
1592 1592
         for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
1593 1593
         return this;
1594 1594
       }
1595  
-      if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name);
  1595
+      if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name);
1596 1596
       priority = "";
1597 1597
     }
1598 1598
     return this.each(d3_selection_style(name, value, priority));
@@ -1654,20 +1654,20 @@
1654 1654
   d3_selectionPrototype.append = function(name) {
1655 1655
     name = d3.ns.qualify(name);
1656 1656
     function append() {
1657  
-      return this.appendChild(document.createElementNS(this.namespaceURI, name));
  1657
+      return this.appendChild(d3_document.createElementNS(this.namespaceURI, name));
1658 1658
     }
1659 1659
     function appendNS() {
1660  
-      return this.appendChild(document.createElementNS(name.space, name.local));
  1660
+      return this.appendChild(d3_document.createElementNS(name.space, name.local));
1661 1661
     }
1662 1662
     return this.select(name.local ? appendNS : append);
1663 1663
   };
1664 1664
   d3_selectionPrototype.insert = function(name, before) {
1665 1665
     name = d3.ns.qualify(name);
1666 1666
     function insert() {
1667  
-      return this.insertBefore(document.createElementNS(this.namespaceURI, name), d3_select(before, this));
  1667
+      return this.insertBefore(d3_document.createElementNS(this.namespaceURI, name), d3_select(before, this));
1668 1668
     }
1669 1669
     function insertNS() {
1670  
-      return this.insertBefore(document.createElementNS(name.space, name.local), d3_select(before, this));
  1670
+      return this.insertBefore(d3_document.createElementNS(name.space, name.local), d3_select(before, this));
1671 1671
     }
1672 1672
     return this.select(name.local ? insertNS : insert);
1673 1673
   };
@@ -1891,7 +1891,7 @@
1891 1891
     }
1892 1892
     return d3_transition(subgroups, id);
1893 1893
   };
1894  
-  var d3_selectionRoot = d3_selection([ [ document ] ]);
  1894
+  var d3_selectionRoot = d3_selection([ [ d3_document ] ]);
1895 1895
   d3_selectionRoot[0].parentNode = d3_selectRoot;
1896 1896
   d3.select = function(selector) {
1897 1897
     return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]);
@@ -2103,7 +2103,7 @@
2103 2103
     }
2104 2104
     return d3_transition_tween(this, "style." + name, value, function(b) {
2105 2105
       function styleString() {
2106  
-        var a = getComputedStyle(this, null).getPropertyValue(name), i;
  2106
+        var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i;
2107 2107
         return a !== b && (i = interpolate(a, b), function(t) {
2108 2108
           this.style.setProperty(name, i(t), priority);
2109 2109
         });
@@ -2114,7 +2114,7 @@
2114 2114
   d3_transitionPrototype.styleTween = function(name, tween, priority) {
2115 2115
     if (arguments.length < 3) priority = "";
2116 2116
     return this.tween("style." + name, function(d, i) {
2117  
-      var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name));
  2117
+      var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name));
2118 2118
       return f && function(t) {
2119 2119
         this.style.setProperty(name, f(t), priority);
2120 2120
       };
@@ -2272,19 +2272,19 @@
2272 2272
     }
2273 2273
     return then;
2274 2274
   }
2275  
-  var d3_timer_frame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
  2275
+  var d3_timer_frame = d3_window.requestAnimationFrame || d3_window.webkitRequestAnimationFrame || d3_window.mozRequestAnimationFrame || d3_window.oRequestAnimationFrame || d3_window.msRequestAnimationFrame || function(callback) {
2276 2276
     setTimeout(callback, 17);
2277 2277
   };
2278 2278
   d3.mouse = function(container) {
2279 2279
     return d3_mousePoint(container, d3_eventSource());
2280 2280
   };
2281  
-  var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
  2281
+  var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;
2282 2282
   function d3_mousePoint(container, e) {
2283 2283
     var svg = container.ownerSVGElement || container;
2284 2284
     if (svg.createSVGPoint) {
2285 2285
       var point = svg.createSVGPoint();
2286  
-      if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) {
2287  
-        svg = d3.select(document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
  2286
+      if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
  2287
+        svg = d3.select(d3_document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
2288 2288
         var ctm = svg[0][0].getScreenCTM();
2289 2289
         d3_mouse_bug44083 = !(ctm.f || ctm.e);
2290 2290
         svg.remove();
@@ -3523,7 +3523,7 @@
3523 3523
     }
3524 3524
     function brushstart() {
3525 3525
       var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), center, origin = mouse(), offset;
3526  
-      var w = d3.select(window).on("mousemove.brush", brushmove).on("mouseup.brush", brushend).on("touchmove.brush", brushmove).on("touchend.brush", brushend).on("keydown.brush", keydown).on("keyup.brush", keyup);
  3526
+      var w = d3.select(d3_window).on("mousemove.brush", brushmove).on("mouseup.brush", brushend).on("touchmove.brush", brushmove).on("touchend.brush", brushend).on("keydown.brush", keydown).on("keyup.brush", keyup);
3527 3527
       if (dragging) {
3528 3528
         origin[0] = extent[0][0] - origin[0];
3529 3529
         origin[1] = extent[0][1] - origin[1];
@@ -3710,7 +3710,7 @@
3710 3710
     }
3711 3711
     function mousedown() {
3712 3712
       var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null, offset, origin_ = point(), moved = 0;
3713  
-      var w = d3.select(window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
  3713
+      var w = d3.select(d3_window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
3714 3714
       if (origin) {
3715 3715
         offset = origin.apply(target, arguments);
3716 3716
         offset = [ offset.x - origin_[0], offset.y - origin_[1] ];
@@ -3833,8 +3833,8 @@
3833 3833
       });
3834 3834
     }
3835 3835
     function mousedown() {
3836  
-      var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target));
3837  
-      window.focus();
  3836
+      var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target));
  3837
+      d3_window.focus();
3838 3838
       d3_eventCancel();
3839 3839
       function mousemove() {
3840 3840
         moved = 1;
8  d3.min.js
4 additions, 4 deletions not shown
10  globals.js
... ...
@@ -1,11 +1,9 @@
1 1
 var document = global.document = require("jsdom").jsdom("<html><head></head><body></body></html>"),
2  
-    window = global.window = document.createWindow(),
3  
-    navigator = global.navigator = window.navigator,
4  
-    getComputedStyle = global.getComputedStyle = window.getComputedStyle,
5  
-    CSSStyleDeclaration = global.CSSStyleDeclaration = window.CSSStyleDeclaration;
  2
+    window = global.window = document.createWindow();
6 3
 
7 4
 // https://github.com/chad3814/CSSStyleDeclaration/issues/3
8  
-var CSSStyleDeclaration_setProperty = CSSStyleDeclaration.prototype.setProperty;
9  
-CSSStyleDeclaration.prototype.setProperty = function(name, value, priority) {
  5
+var CSSStyleDeclaration_prototype = window.CSSStyleDeclaration.prototype,
  6
+    CSSStyleDeclaration_setProperty = CSSStyleDeclaration_prototype.setProperty;
  7
+CSSStyleDeclaration_prototype.setProperty = function(name, value, priority) {
10 8
   return CSSStyleDeclaration_setProperty.call(this, name + "", value == null ? null : value + "", priority == null ? null : priority + "");
11 9
 };
2  index.js
... ...
@@ -1,4 +1,4 @@
1  
-var globals = ["document", "window", "navigator", "CSSStyleDeclaration", "getComputedStyle", "d3"],
  1
+var globals = ["document", "window", "d3"],
2 2
     globalValues = {};
3 3
 
4 4
 globals.forEach(function(g) {
2  src/behavior/drag.js
@@ -16,7 +16,7 @@ d3.behavior.drag = function() {
16 16
         origin_ = point(),
17 17
         moved = 0;
18 18
 
19  
-    var w = d3.select(window)
  19
+    var w = d3.select(d3_window)
20 20
         .on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove)
21 21
         .on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
22 22
 
4  src/behavior/zoom.js
@@ -95,10 +95,10 @@ d3.behavior.zoom = function() {
95 95
         event_ = event.of(target, arguments),
96 96
         eventTarget = d3.event.target,
97 97
         moved = 0,
98  
-        w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup),
  98
+        w = d3.select(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup),
99 99
         l = location(d3.mouse(target));
100 100
 
101  
-    window.focus();
  101
+    d3_window.focus();
102 102
     d3_eventCancel();
103 103
 
104 104
     function mousemove() {
4  src/compat/style.js
... ...
@@ -1,7 +1,7 @@
1 1
 try {
2  
-  document.createElement("div").style.setProperty("opacity", 0, "");
  2
+  d3_document.createElement("div").style.setProperty("opacity", 0, "");
3 3
 } catch (error) {
4  
-  var d3_style_prototype = CSSStyleDeclaration.prototype,
  4
+  var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype,
5 5
       d3_style_setProperty = d3_style_prototype.setProperty;
6 6
   d3_style_prototype.setProperty = function(name, value, priority) {
7 7
     d3_style_setProperty.call(this, name, value + "", priority);
2  src/core/array.js
@@ -11,7 +11,7 @@ function d3_arraySlice(pseudoarray) {
11 11
 }
12 12
 
13 13
 try {
14  
-  d3_array(document.documentElement.childNodes)[0].nodeType;
  14
+  d3_array(d3_document.documentElement.childNodes)[0].nodeType;
15 15
 } catch(e) {
16 16
   d3_array = d3_arrayCopy;
17 17
 }
4  src/core/core.js
@@ -3,7 +3,9 @@ d3 = {version: "3.0.5"}; // semver
3 3
 var π = Math.PI,
4 4
     ε = 1e-6,
5 5
     d3_radians = π / 180,
6  
-    d3_degrees = 180 / π;
  6
+    d3_degrees = 180 / π,
  7
+    d3_document = document,
  8
+    d3_window = window;
7 9
 
8 10
 function d3_target(d) {
9 11
   return d.target;
4  src/core/html.js
@@ -3,7 +3,7 @@ d3.html = function(url, callback) {
3 3
 };
4 4
 
5 5
 function d3_html(request) {
6  
-  var range = document.createRange();
7  
-  range.selectNode(document.body);
  6
+  var range = d3_document.createRange();
  7
+  range.selectNode(d3_document.body);
8 8
   return range.createContextualFragment(request.responseText);
9 9
 }
7  src/core/mouse.js
@@ -3,15 +3,14 @@ d3.mouse = function(container) {
3 3
 };
4 4
 
5 5
 // https://bugs.webkit.org/show_bug.cgi?id=44083
6  
-var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
  6
+var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;
7 7
 
8 8
 function d3_mousePoint(container, e) {
9 9
   var svg = container.ownerSVGElement || container;
10 10
   if (svg.createSVGPoint) {
11 11
     var point = svg.createSVGPoint();
12  
-    if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) {
13  
-      svg = d3.select(document.body)
14  
-        .append("svg")
  12
+    if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
  13
+      svg = d3.select(d3_document.body).append("svg")
15 14
           .style("position", "absolute")
16 15
           .style("top", 0)
17 16
           .style("left", 0);
4  src/core/selection-append.js
@@ -4,11 +4,11 @@ d3_selectionPrototype.append = function(name) {
4 4
   name = d3.ns.qualify(name);
5 5
 
6 6
   function append() {
7  
-    return this.appendChild(document.createElementNS(this.namespaceURI, name));
  7
+    return this.appendChild(d3_document.createElementNS(this.namespaceURI, name));
8 8
   }
9 9
 
10 10
   function appendNS() {
11  
-    return this.appendChild(document.createElementNS(name.space, name.local));
  11
+    return this.appendChild(d3_document.createElementNS(name.space, name.local));
12 12
   }
13 13
 
14 14
   return this.select(name.local ? appendNS : append);
4  src/core/selection-insert.js
@@ -6,13 +6,13 @@ d3_selectionPrototype.insert = function(name, before) {
6 6
 
7 7
   function insert() {
8 8
     return this.insertBefore(
9  
-        document.createElementNS(this.namespaceURI, name),
  9
+        d3_document.createElementNS(this.namespaceURI, name),
10 10
         d3_select(before, this));
11 11
   }
12 12
 
13 13
   function insertNS() {
14 14
     return this.insertBefore(
15  
-        document.createElementNS(name.space, name.local),
  15
+        d3_document.createElementNS(name.space, name.local),
16 16
         d3_select(before, this));
17 17
   }
18 18
 
2  src/core/selection-root.js
... ...
@@ -1,4 +1,4 @@
1  
-var d3_selectionRoot = d3_selection([[document]]);
  1
+var d3_selectionRoot = d3_selection([[d3_document]]);
2 2
 
3 3
 d3_selectionRoot[0].parentNode = d3_selectRoot;
4 4
 
2  src/core/selection-style.js
@@ -13,7 +13,7 @@ d3_selectionPrototype.style = function(name, value, priority) {
13 13
     }
14 14
 
15 15
     // For style(string), return the computed style value for the first node.
16  
-    if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name);
  16
+    if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name);
17 17
 
18 18
     // For style(string, string) or style(string, function), use the default
19 19
     // priority. The priority is ignored for style(string, null).
2  src/core/selection.js
@@ -5,7 +5,7 @@ function d3_selection(groups) {
5 5
 
6 6
 var d3_select = function(s, n) { return n.querySelector(s); },
7 7
     d3_selectAll = function(s, n) { return n.querySelectorAll(s); },
8  
-    d3_selectRoot = document.documentElement,
  8
+    d3_selectRoot = d3_document.documentElement,
9 9
     d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector,
10 10
     d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); };
11 11
 
10  src/core/timer.js
@@ -90,9 +90,9 @@ function d3_timer_flush() {
90 90
   return then;
91 91
 }
92 92
 
93  
-var d3_timer_frame = window.requestAnimationFrame
94  
-    || window.webkitRequestAnimationFrame
95  
-    || window.mozRequestAnimationFrame
96  
-    || window.oRequestAnimationFrame
97  
-    || window.msRequestAnimationFrame
  93
+var d3_timer_frame = d3_window.requestAnimationFrame
  94
+    || d3_window.webkitRequestAnimationFrame
  95
+    || d3_window.mozRequestAnimationFrame
  96
+    || d3_window.oRequestAnimationFrame
  97
+    || d3_window.msRequestAnimationFrame
98 98
     || function(callback) { setTimeout(callback, 17); };
2  src/core/transform.js
... ...
@@ -1,5 +1,5 @@
1 1
 d3.transform = function(string) {
2  
-  var g = document.createElementNS(d3.ns.prefix.svg, "g");
  2
+  var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
3 3
   return (d3.transform = function(string) {
4 4
     g.setAttribute("transform", string);
5 5
     var t = g.transform.baseVal.consolidate();
4  src/core/transition-style.js
@@ -31,7 +31,7 @@ d3_transitionPrototype.style = function(name, value, priority) {
31 31
     // For style(name, string) or style(name, string, priority), set the style
32 32
     // property with the specified name, using the specified priority.
33 33
     function styleString() {
34  
-      var a = getComputedStyle(this, null).getPropertyValue(name), i;
  34
+      var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i;
35 35
       return a !== b && (i = interpolate(a, b), function(t) { this.style.setProperty(name, i(t), priority); });
36 36
     }
37 37
 
@@ -43,7 +43,7 @@ d3_transitionPrototype.style = function(name, value, priority) {
43 43
 d3_transitionPrototype.styleTween = function(name, tween, priority) {
44 44
   if (arguments.length < 3) priority = "";
45 45
   return this.tween("style." + name, function(d, i) {
46  
-    var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name));
  46
+    var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name));
47 47
     return f && function(t) { this.style.setProperty(name, f(t), priority); };
48 48
   });
49 49
 };
2  src/core/xhr.js
@@ -3,7 +3,7 @@ d3.xhr = function(url, mimeType, callback) {
3 3
       dispatch = d3.dispatch("progress", "load", "error"),
4 4
       headers = {},
5 5
       response = d3_identity,
6  
-      request = new (window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest);
  6
+      request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest);
7 7
 
8 8
   "onload" in request
9 9
       ? request.onload = request.onerror = respond
2  src/svg/brush.js
@@ -93,7 +93,7 @@ d3.svg.brush = function() {
93 93
         origin = mouse(),
94 94
         offset;
95 95
 
96  
-    var w = d3.select(window)
  96
+    var w = d3.select(d3_window)
97 97
         .on("mousemove.brush", brushmove)
98 98
         .on("mouseup.brush", brushend)
99 99
         .on("touchmove.brush", brushmove)

0 notes on commit 0991f3b

Please sign in to comment.
Something went wrong with that request. Please try again.