Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ZeeAgency/d3 into v2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Feb 22, 2012
2 parents 589b12f + 474dfec commit 34667bf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
3 changes: 3 additions & 0 deletions d3.v2.js
Expand Up @@ -2022,6 +2022,9 @@ function d3_selection_enter(selection) {

var d3_selection_enterPrototype = [];

d3.selection.enter = d3_selection_enter;
d3.selection.enter.prototype = d3_selection_enterPrototype;

d3_selection_enterPrototype.append = d3_selectionPrototype.append;
d3_selection_enterPrototype.insert = d3_selectionPrototype.insert;
d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
Expand Down
6 changes: 3 additions & 3 deletions d3.v2.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/core/selection-enter.js
Expand Up @@ -5,6 +5,9 @@ function d3_selection_enter(selection) {

var d3_selection_enterPrototype = [];

d3.selection.enter = d3_selection_enter;
d3.selection.enter.prototype = d3_selection_enterPrototype;

d3_selection_enterPrototype.append = d3_selectionPrototype.append;
d3_selection_enterPrototype.insert = d3_selectionPrototype.insert;
d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
Expand Down
25 changes: 25 additions & 0 deletions test/core/selection-enter-test.js
@@ -0,0 +1,25 @@
require("../env");

var vows = require("vows"),
assert = require("assert");

var suite = vows.describe("selection.enter");

suite.addBatch({
"selectAll(div)": {
topic: function() {
return d3.select("body").html("").selectAll("div").data(d3.range(2)).enter();
},
"is an instanceof d3.selection.enter": function(enter) {
assert.instanceOf(enter, d3.selection.enter);
},
"selection prototype can be extended": function(enter) {
d3.selection.enter.prototype.foo = function() { return this.append("foo"); };
var selection = enter.foo();
assert.equal(document.body.innerHTML, "<foo></foo><foo></foo>");
delete d3.selection.enter.prototype.foo;
}
}
});

suite.export(module);
6 changes: 3 additions & 3 deletions test/core/selection-test.js
Expand Up @@ -16,11 +16,11 @@ suite.addBatch({
assert.equal(selection[0][0], document);
},
"is an instanceof d3.selection": function(selection) {
assert.isTrue(selection instanceof d3.selection);
assert.instanceOf(selection, d3.selection);
},
"subselections are also instanceof d3.selection": function(selection) {
assert.isTrue(selection.select("body") instanceof d3.selection);
assert.isTrue(selection.selectAll("body") instanceof d3.selection);
assert.instanceOf(selection.select("body"), d3.selection);
assert.instanceOf(selection.selectAll("body"), d3.selection);
},
"selection prototype can be extended": function(selection) {
d3.selection.prototype.foo = function(v) { return this.attr("foo", v); };
Expand Down

0 comments on commit 34667bf

Please sign in to comment.