Permalink
Browse files

Ack, Sizzle doesn't sort by default.

The Selectors API guarantees that results are returned in document order, but
Sizzle does not, by default. So now we sort the results when using Sizzle. Yay
tests!
  • Loading branch information...
1 parent 50ebc15 commit eaed6b880bc5550ad0a6b3a4542f6f8534a6a6da @mbostock mbostock committed Mar 5, 2011
Showing with 90 additions and 27 deletions.
  1. +2 −0 Makefile
  2. +2 −2 d3.js
  3. +23 −23 d3.min.js
  4. +1 −1 src/core/core.js
  5. +1 −1 src/core/selection.js
  6. +15 −0 tests/test-append.js
  7. +6 −0 tests/test-append.out
  8. +24 −0 tests/test-attr.js
  9. +16 −0 tests/test-attr.out
View
@@ -134,6 +134,8 @@ d3.geom.js: \
src/end.js
tests: \
+ tests/test-append.test \
+ tests/test-attr.test \
tests/test-format.test
%.min.js: %.js Makefile
View
@@ -1,4 +1,4 @@
-(function(){d3 = {version: "1.5.1"}; // semver
+(function(){d3 = {version: "1.5.2"}; // semver
if (!Date.now) Date.now = function() {
return +new Date();
};
@@ -995,7 +995,7 @@ var d3_select = function(s, n) { return n.querySelector(s); },
// Use Sizzle, if available.
if (typeof Sizzle == "function") {
d3_select = function(s, n) { return Sizzle(s, n)[0]; };
- d3_selectAll = Sizzle;
+ d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
}
var d3_root = d3_selection([[document]]);
View
Oops, something went wrong.
View
@@ -1 +1 @@
-d3 = {version: "1.5.1"}; // semver
+d3 = {version: "1.5.2"}; // semver
@@ -4,7 +4,7 @@ var d3_select = function(s, n) { return n.querySelector(s); },
// Use Sizzle, if available.
if (typeof Sizzle == "function") {
d3_select = function(s, n) { return Sizzle(s, n)[0]; };
- d3_selectAll = Sizzle;
+ d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
}
var d3_root = d3_selection([[document]]);
View
@@ -0,0 +1,15 @@
+require("./../lib/env-js/envjs/node");
+require("./../lib/sizzle/sizzle");
+require("./../d3");
+
+d3.select("body").append("svg:svg");
+
+console.log("append svg:svg:");
+console.log(" ", document.body.innerHTML);
+console.log("");
+
+d3.select("body").append("div");
+
+console.log("append div:");
+console.log(" ", document.body.innerHTML);
+console.log("");
@@ -0,0 +1,6 @@
+append svg:svg:
+ <svg/>
+
+append div:
+ <svg/><div/>
+
View
@@ -0,0 +1,24 @@
+require("./../lib/env-js/envjs/node");
+require("./../lib/sizzle/sizzle");
+require("./../d3");
+
+d3.select("body").append("svg:svg")
+ .attr("width", "960")
+ .attr("height", "500");
+
+console.log("constant attr:");
+console.log(" ", document.body.innerHTML);
+console.log("");
+
+d3.select("body").selectAll("div")
+ .data("abcdefghijk".split(""))
+ .enter().append("div")
+ .attr("value", function(d, i) { return d; })
+ .attr("index", function(d, i) { return i; });
+
+console.log("function attr:");
+d3.selectAll("div").each(function() {
+ var d = d3.select(this);
+ console.log(" ", d.attr("value"), d.attr("index"));
+});
+console.log("");
View
@@ -0,0 +1,16 @@
+constant attr:
+ <svg width="960" height="500"/>
+
+function attr:
+ a 0
+ b 1
+ c 2
+ d 3
+ e 4
+ f 5
+ g 6
+ h 7
+ i 8
+ j 9
+ k 10
+

0 comments on commit eaed6b8

Please sign in to comment.