-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These are primarily intended for use by d3-transition, but they might have other uses (such as caching closures for optimization).
- Loading branch information
Showing
7 changed files
with
132 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
export {default as creator} from "./src/creator"; | ||
export {default as matcher} from "./src/matcher"; | ||
export {default as mouse} from "./src/mouse"; | ||
export {default as namespace} from "./src/namespace"; | ||
export {default as namespaces} from "./src/namespaces"; | ||
export {default as select} from "./src/select"; | ||
export {default as selectAll} from "./src/selectAll"; | ||
export {default as selection} from "./src/selection/index"; | ||
export {default as selector} from "./src/selector"; | ||
export {default as selectorAll} from "./src/selectorAll"; | ||
export {default as touch} from "./src/touch"; | ||
export {default as touches} from "./src/touches"; | ||
export {event} from "./src/selection/on"; |
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,24 @@ | ||
var tape = require("tape"), | ||
jsdom = require("jsdom"), | ||
d3 = require("../"); | ||
|
||
tape("d3.creator(name).call(element) returns a new element with the given name", function(test) { | ||
var document = jsdom.jsdom("<body class='foo'>"); | ||
test.deepEqual(type(d3.creator("h1").call(document.body)), {namespace: "http://www.w3.org/1999/xhtml", name: "H1"}); | ||
test.deepEqual(type(d3.creator("xhtml:h1").call(document.body)), {namespace: "http://www.w3.org/1999/xhtml", name: "H1"}); | ||
test.deepEqual(type(d3.creator("svg").call(document.body)), {namespace: "http://www.w3.org/2000/svg", name: "svg"}); | ||
test.deepEqual(type(d3.creator("g").call(document.body)), {namespace: "http://www.w3.org/1999/xhtml", name: "G"}); | ||
test.end(); | ||
}); | ||
|
||
tape("d3.creator(name).call(element) can inherit the namespace from the given element", function(test) { | ||
var document = jsdom.jsdom("<body class='foo'><svg></svg>"), | ||
svg = document.querySelector("svg"); | ||
test.deepEqual(type(d3.creator("g").call(document.body)), {namespace: "http://www.w3.org/1999/xhtml", name: "G"}); | ||
test.deepEqual(type(d3.creator("g").call(svg)), {namespace: "http://www.w3.org/2000/svg", name: "g"}); | ||
test.end(); | ||
}); | ||
|
||
function type(element) { | ||
return {namespace: element.namespaceURI, name: element.tagName}; | ||
} |
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,13 @@ | ||
var tape = require("tape"), | ||
jsdom = require("jsdom"), | ||
d3 = require("../"); | ||
|
||
tape("d3.matcher(selector).call(element) returns true if the element matches the selector", function(test) { | ||
var document = jsdom.jsdom("<body class='foo'>"); | ||
test.equal(d3.matcher("body").call(document.body), true); | ||
test.equal(d3.matcher(".foo").call(document.body), true); | ||
test.equal(d3.matcher("body.foo").call(document.body), true); | ||
test.equal(d3.matcher("h1").call(document.body), false); | ||
test.equal(d3.matcher("body.bar").call(document.body), false); | ||
test.end(); | ||
}); |
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,13 @@ | ||
var tape = require("tape"), | ||
jsdom = require("jsdom"), | ||
d3 = require("../"); | ||
|
||
tape("d3.selector(selector).call(element) returns the first element that matches the selector", function(test) { | ||
var document = jsdom.jsdom("<body class='foo'>"); | ||
test.equal(d3.selector("body").call(document.documentElement), document.body); | ||
test.equal(d3.selector(".foo").call(document.documentElement), document.body); | ||
test.equal(d3.selector("body.foo").call(document.documentElement), document.body); | ||
test.equal(d3.selector("h1").call(document.documentElement), null); | ||
test.equal(d3.selector("body.bar").call(document.documentElement), null); | ||
test.end(); | ||
}); |
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,17 @@ | ||
var tape = require("tape"), | ||
jsdom = require("jsdom"), | ||
d3 = require("../"); | ||
|
||
tape("d3.selectorAll(selector).call(element) returns all elements that match the selector", function(test) { | ||
var document = jsdom.jsdom("<body class='foo'><div class='foo'>"), | ||
body = document.body, | ||
div = document.querySelector("div"); | ||
test.deepEqual(d3.selectorAll("body").call(document.documentElement), [body]); | ||
test.deepEqual(d3.selectorAll(".foo").call(document.documentElement), [body, div]); | ||
test.deepEqual(d3.selectorAll("div.foo").call(document.documentElement), [div]); | ||
test.deepEqual(d3.selectorAll("div").call(document.documentElement), [div]); | ||
test.deepEqual(d3.selectorAll("div,body").call(document.documentElement), [body,div]); | ||
test.deepEqual(d3.selectorAll("h1").call(document.documentElement), []); | ||
test.deepEqual(d3.selectorAll("body.bar").call(document.documentElement), []); | ||
test.end(); | ||
}); |