-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #121; add transition.selectChild[ren]
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import assert from "assert"; | ||
import {selectAll} from "d3-selection"; | ||
import {transition} from "../../src/index.js"; | ||
import it from "../jsdom.js"; | ||
|
||
it("transition.selectChild(selector) selects the child matching the specified selector, then derives a transition", "<h1 id='one'><child/></h1><h1 id='two'><child/></h1>", () => { | ||
const one = document.querySelector("#one"); | ||
const two = document.querySelector("#two"); | ||
const t1 = selectAll([one, two]).data([1, 2]).transition().delay(function(d) { return d * 10; }); | ||
const t2 = t1.selectChild("child"); | ||
assert.strictEqual(t2 instanceof transition, true); | ||
assert.deepStrictEqual(t2._groups, [[one.firstChild, two.firstChild]]); | ||
assert.strictEqual(t2._parents, t1._parents); | ||
assert.strictEqual(t2._name, t1._name); | ||
assert.strictEqual(t2._id, t1._id); | ||
assert.strictEqual(one.firstChild.__data__, 1); | ||
assert.strictEqual(two.firstChild.__data__, 2); | ||
assert.strictEqual(one.firstChild.__transition[t1._id].delay, 10); | ||
assert.strictEqual(two.firstChild.__transition[t1._id].delay, 20); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import assert from "assert"; | ||
import {selectAll} from "d3-selection"; | ||
import {transition} from "../../src/index.js"; | ||
import it from "../jsdom.js"; | ||
|
||
it("transition.selectChildren(selector) selects the children matching the specified selector, then derives a transition", "<h1 id='one'><child/></h1><h1 id='two'><child/></h1>", () => { | ||
const one = document.querySelector("#one"); | ||
const two = document.querySelector("#two"); | ||
const t1 = selectAll([one, two]).data([1, 2]).transition().delay(function(d) { return d * 10; }); | ||
const t2 = t1.selectChildren("child"); | ||
assert.strictEqual(t2 instanceof transition, true); | ||
assert.deepStrictEqual(t2._groups.map(group => Array.from(group)), [[one.firstChild], [two.firstChild]]); | ||
assert.deepStrictEqual(t2._parents, [one, two]); | ||
assert.strictEqual(t2._name, t1._name); | ||
assert.strictEqual(t2._id, t1._id); | ||
assert.strictEqual("__data__" in one.firstChild, false); | ||
assert.strictEqual("__data__" in two.firstChild, false); | ||
assert.strictEqual(one.firstChild.__transition[t1._id].delay, 10); | ||
assert.strictEqual(two.firstChild.__transition[t1._id].delay, 20); | ||
}); |