Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
2 parents c974d3a + 80fafd5 commit 151d09d47956d507f2d0a67f56b135c233a59d83 @mbostock mbostock committed Sep 27, 2011
Showing with 55 additions and 11 deletions.
  1. +24 −4 d3.js
  2. +2 −2 d3.min.js
  3. +1 −1 package.json
  4. +18 −0 src/core/array.js
  5. +1 −1 src/core/core.js
  6. +3 −1 src/core/selection-root.js
  7. +1 −1 src/core/selection-selectAll.js
  8. +1 −1 src/svg/touches.js
  9. +4 −0 test/core/selectAll-test.js
View
28 d3.js
@@ -10,7 +10,25 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
-d3 = {version: "2.2.0"}; // semver
+d3 = {version: "2.2.1"}; // semver
+var d3_array = d3_arraySlice; // conversion for NodeLists
+
+function d3_arrayCopy(pseudoarray) {
+ var i = -1, n = pseudoarray.length, array = [];
+ while (++i < n) array.push(pseudoarray[i]);
+ return array;
+}
+
+function d3_arraySlice(pseudoarray) {
+ return Array.prototype.slice.call(pseudoarray);
+}
+
+try {
+ d3_array(document.documentElement.childNodes)[0].nodeType;
+} catch(e) {
+ d3_array = d3_arrayCopy;
+}
+
var d3_arraySubclass = [].__proto__?
// Until ECMAScript supports array subclassing, prototype injection works well.
@@ -1254,7 +1272,7 @@ d3_selectionPrototype.selectAll = function(selector) {
for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
- subgroups.push(subgroup = selector.call(node, node.__data__, i));
+ subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));
subgroup.parentNode = node;
}
}
@@ -1738,16 +1756,18 @@ var d3_selectionRoot = d3_selection([[document]]);
d3_selectionRoot[0].parentNode = document.documentElement;
// TODO fast singleton implementation!
+// TODO select(function)
d3.select = function(selector) {
return typeof selector === "string"
? d3_selectionRoot.select(selector)
: d3_selection([[selector]]); // assume node
};
+// TODO selectAll(function)
d3.selectAll = function(selector) {
return typeof selector === "string"
? d3_selectionRoot.selectAll(selector)
- : d3_selection([selector]); // assume node[]
+ : d3_selection([d3_array(selector)]); // assume node[]
};
function d3_transition(groups, id) {
d3_arraySubclass(groups, d3_transitionPrototype);
@@ -3401,7 +3421,7 @@ function d3_svg_mousePoint(container, e) {
};
d3.svg.touches = function(container) {
var touches = d3.event.touches;
- return touches ? Array.prototype.map.call(touches, function(touch) {
+ return touches ? d3_array(touches).map(function(touch) {
var point = d3_svg_mousePoint(container, touch);
point.identifier = touch.identifier;
return point;
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "d3",
- "version": "2.2.0",
+ "version": "2.2.1",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
View
@@ -1,3 +1,21 @@
+var d3_array = d3_arraySlice; // conversion for NodeLists
+
+function d3_arrayCopy(pseudoarray) {
+ var i = -1, n = pseudoarray.length, array = [];
+ while (++i < n) array.push(pseudoarray[i]);
+ return array;
+}
+
+function d3_arraySlice(pseudoarray) {
+ return Array.prototype.slice.call(pseudoarray);
+}
+
+try {
+ d3_array(document.documentElement.childNodes)[0].nodeType;
+} catch(e) {
+ d3_array = d3_arrayCopy;
+}
+
var d3_arraySubclass = [].__proto__?
// Until ECMAScript supports array subclassing, prototype injection works well.
View
@@ -1 +1 @@
-d3 = {version: "2.2.0"}; // semver
+d3 = {version: "2.2.1"}; // semver
@@ -3,14 +3,16 @@ var d3_selectionRoot = d3_selection([[document]]);
d3_selectionRoot[0].parentNode = document.documentElement;
// TODO fast singleton implementation!
+// TODO select(function)
d3.select = function(selector) {
return typeof selector === "string"
? d3_selectionRoot.select(selector)
: d3_selection([[selector]]); // assume node
};
+// TODO selectAll(function)
d3.selectAll = function(selector) {
return typeof selector === "string"
? d3_selectionRoot.selectAll(selector)
- : d3_selection([selector]); // assume node[]
+ : d3_selection([d3_array(selector)]); // assume node[]
};
@@ -8,7 +8,7 @@ d3_selectionPrototype.selectAll = function(selector) {
for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
- subgroups.push(subgroup = selector.call(node, node.__data__, i));
+ subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));
subgroup.parentNode = node;
}
}
View
@@ -1,6 +1,6 @@
d3.svg.touches = function(container) {
var touches = d3.event.touches;
- return touches ? Array.prototype.map.call(touches, function(touch) {
+ return touches ? d3_array(touches).map(function(touch) {
var point = d3_svg_mousePoint(container, touch);
point.identifier = touch.identifier;
return point;
@@ -35,6 +35,10 @@ suite.addBatch({
assert.isTrue(div[0][0] === document.body.lastChild);
assert.length(div, 1);
assert.length(div[0], 1);
+ },
+ "groups are not instances of NodeList": function() {
+ var div = d3.select("body").selectAll(function() { return this.getElementsByClassName("div"); });
+ assert.isFalse(div[0] instanceof window.NodeList);
}
}
});

0 comments on commit 151d09d

Please sign in to comment.