Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add <- appendChild, insertBefore remove <- removeChild parent <- parentNode child <- firstChild, lastChild, childNodes[i] previous <- previousSibling next <- nextSibling on <- addEventListener off <- removeEventListener Also, n$(string) will create an "offscreen" element, and n$(null) will return null. This commit also rewrites the NNS to use traditional JavaScript prototypes to avoid creating any per-instance closures. This seems prudent given that NNS objects should be cheap to create. A minimized version of nns.js is also included.
- Loading branch information
Mike Bostock
committed
Jul 16, 2010
1 parent
c210c5f
commit 64cd2e0
Showing
6 changed files
with
210 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
JS_COMPILER = \ | ||
java -jar /Library/Google/Compiler/compiler-20100201.jar \ | ||
--charset UTF-8 | ||
|
||
all: nns.min.js | ||
|
||
nns.min.js: nns.js Makefile | ||
rm -f $@ | ||
$(JS_COMPILER) < nns.js >> $@ | ||
chmod a-w $@ | ||
|
||
clean: | ||
rm nns.min.js |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,43 @@ | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="../nns.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
var svg = n$(document.body).add("svg:svg") | ||
.attr("width", 200) | ||
.attr("height", 200) | ||
.style("font", "12pt Helvetica Neue") | ||
.style("text-rendering", "optimizeLegibility"); | ||
|
||
svg.add("svg:rect") | ||
.attr("width", "100%") | ||
.attr("height", "100%") | ||
.attr("fill", "none") | ||
.attr("stroke", "black"); | ||
|
||
svg.add("svg:text") | ||
.attr("x", "50%") | ||
.attr("y", "25%") | ||
.attr("dy", ".35em") | ||
.attr("text-anchor", "middle") | ||
.text("n$(null): " + (n$(null) === null ? "PASS" : "FAIL")); | ||
|
||
svg.add("svg:text") | ||
.attr("x", "50%") | ||
.attr("y", "50%") | ||
.attr("dy", ".35em") | ||
.attr("text-anchor", "middle") | ||
.text("n$(undefined): " + (n$(undefined) === undefined ? "PASS" : "FAIL")); | ||
|
||
svg.add("svg:text") | ||
.attr("x", "50%") | ||
.attr("y", "75%") | ||
.attr("dy", ".35em") | ||
.attr("text-anchor", "middle") | ||
.text("n$(): " + (n$() == undefined ? "PASS" : "FAIL")); | ||
|
||
</script> | ||
</body> | ||
</html> |
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,31 @@ | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="../nns.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
var svg = n$(document.body).add("svg:svg") | ||
.attr("width", 200) | ||
.attr("height", 200) | ||
.style("font", "36pt Helvetica Neue") | ||
.style("text-rendering", "optimizeLegibility"); | ||
|
||
svg.add("svg:rect") | ||
.attr("width", "100%") | ||
.attr("height", "100%") | ||
.attr("fill", "none") | ||
.attr("stroke", "black"); | ||
|
||
var text = n$("svg:text") | ||
.attr("x", "50%") | ||
.attr("y", "50%") | ||
.attr("dy", ".35em") | ||
.attr("text-anchor", "middle") | ||
.text("PASS"); | ||
|
||
svg.add(text); | ||
|
||
</script> | ||
</body> | ||
</html> |
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,36 @@ | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="../nns.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
var svg = n$(document.body).add("svg:svg") | ||
.attr("width", 200) | ||
.attr("height", 200) | ||
.style("font", "24pt Helvetica Neue") | ||
.style("text-rendering", "optimizeLegibility"); | ||
|
||
svg.add("svg:rect") | ||
.attr("width", "100%") | ||
.attr("height", "100%") | ||
.attr("fill", "none") | ||
.attr("stroke", "black"); | ||
|
||
n$(svg).add("svg:text") | ||
.attr("x", "50%") | ||
.attr("y", "33%") | ||
.attr("dy", ".35em") | ||
.attr("text-anchor", "middle") | ||
.text("PASS"); | ||
|
||
svg.add(n$("svg:text")) | ||
.attr("x", "50%") | ||
.attr("y", "67%") | ||
.attr("dy", ".35em") | ||
.attr("text-anchor", "middle") | ||
.text("PASS"); | ||
|
||
</script> | ||
</body> | ||
</html> |