Skip to content

Commit

Permalink
Fix missing d3.transition in IE. Fixes d3#1491.
Browse files Browse the repository at this point in the history
IE doesn’t support __proto__ patching, so if the selection.prototype.transition
method isn’t yet defined at the time d3_selectionRoot is defined, it won’t
inherit the method when the prototype is patched later! This restores the
original order of dependencies so that the transition method is defined before
d3_selectionRoot is created.
  • Loading branch information
mbostock committed Aug 27, 2013
1 parent 354f54d commit fc5a586
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.3.1",
"version": "3.3.2",
"main": "d3.js",
"scripts": [
"d3.js"
Expand Down
2 changes: 1 addition & 1 deletion component.json
Expand Up @@ -10,7 +10,7 @@
"animation",
"canvas"
],
"version": "3.3.1",
"version": "3.3.2",
"main": "index-browserify.js",
"scripts": [
"d3.js",
Expand Down
48 changes: 24 additions & 24 deletions d3.js
@@ -1,6 +1,6 @@
d3 = function() {
var d3 = {
version: "3.3.1"
version: "3.3.2"
};
if (!Date.now) Date.now = function() {
return +new Date();
Expand Down Expand Up @@ -943,6 +943,29 @@ d3 = function() {
return node;
};
}
d3_selectionPrototype.transition = function() {
var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || {
time: Date.now(),
ease: d3_ease_cubicInOut,
delay: 0,
duration: 250
};
for (var j = -1, m = this.length; ++j < m; ) {
subgroups.push(subgroup = []);
for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
if (node = group[i]) d3_transitionNode(node, i, id, transition);
subgroup.push(node);
}
}
return d3_transition(subgroups, id);
};
d3_selectionPrototype.interrupt = function() {
return this.each(d3_selection_interrupt);
};
function d3_selection_interrupt() {
var lock = this.__transition__;
if (lock) ++lock.active;
}
d3.select = function(node) {
var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
group.parentNode = d3_documentElement;
Expand Down Expand Up @@ -7584,29 +7607,6 @@ d3 = function() {
return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition();
};
d3.transition.prototype = d3_transitionPrototype;
d3_selectionPrototype.transition = function() {
var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || {
time: Date.now(),
ease: d3_ease_cubicInOut,
delay: 0,
duration: 250
};
for (var j = -1, m = this.length; ++j < m; ) {
subgroups.push(subgroup = []);
for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
if (node = group[i]) d3_transitionNode(node, i, id, transition);
subgroup.push(node);
}
}
return d3_transition(subgroups, id);
};
d3_selectionPrototype.interrupt = function() {
return this.each(d3_selection_interrupt);
};
function d3_selection_interrupt() {
var lock = this.__transition__;
if (lock) ++lock.active;
}
d3_transitionPrototype.select = function(selector) {
var id = this.id, subgroups = [], subgroup, subnode, node;
selector = d3_selection_selector(selector);
Expand Down
10 changes: 5 additions & 5 deletions d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.3.1",
"version": "3.3.2",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
Expand Down
2 changes: 1 addition & 1 deletion src/selection/interrupt.js
@@ -1,4 +1,4 @@
import "../transition/transition";
// import "../transition/transition";
import "selection";

d3_selectionPrototype.interrupt = function() {
Expand Down
3 changes: 3 additions & 0 deletions src/selection/selection.js
Expand Up @@ -50,6 +50,9 @@ import "node";
import "size";
import "enter";

import "transition";
import "interrupt";

// TODO fast singleton implementation?
d3.select = function(node) {
var group = [typeof node === "string" ? d3_select(node, d3_document) : node];
Expand Down
2 changes: 1 addition & 1 deletion src/selection/transition.js
@@ -1,4 +1,4 @@
import "../transition/transition";
// import "../transition/transition";
import "selection";

d3_selectionPrototype.transition = function() {
Expand Down
2 changes: 1 addition & 1 deletion src/start.js
@@ -1,2 +1,2 @@
d3 = (function(){
var d3 = {version: "3.3.1"}; // semver
var d3 = {version: "3.3.2"}; // semver
3 changes: 0 additions & 3 deletions src/transition/transition.js
Expand Up @@ -31,9 +31,6 @@ d3.transition = function(selection) {

d3.transition.prototype = d3_transitionPrototype;

import "../selection/transition";
import "../selection/interrupt";

import "select";
import "selectAll";
import "filter";
Expand Down
2 changes: 1 addition & 1 deletion test/selection/interrupt-test.js
Expand Up @@ -6,7 +6,7 @@ var suite = vows.describe("selection.interrupt");

suite.addBatch({
"interrupt": {
topic: load("selection/interrupt").document(),
topic: load("transition/transition").document(),
"returns the current selection": function(d3) {
var selection = d3.select("body").append("div");
assert.strictEqual(selection.interrupt(), selection);
Expand Down

0 comments on commit fc5a586

Please sign in to comment.