Skip to content

Commit

Permalink
Better comments. Test most-specific first.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 5, 2012
1 parent ce8852b commit b20c823
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
14 changes: 7 additions & 7 deletions d3.v2.js
Expand Up @@ -1390,18 +1390,18 @@
}
d3_selectionPrototype.attr = function(name, value) {
if (arguments.length < 2) {
if ((value = typeof name) === "object") {
for (value in name) this.attr(value, name[value]);
return this;
}
if (value === "function") {
if ((value = typeof name) === "function") {
return this.each(function() {
var x = name.apply(this, arguments);
for (value in x) d3_selection_attr(value, x[value]).apply(this, arguments);
});
}
value = this.node();
return (name = d3.ns.qualify(name)).local ? value.getAttributeNS(name.space, name.local) : value.getAttribute(name);
if (value === "string") {
value = this.node();
return (name = d3.ns.qualify(name)).local ? value.getAttributeNS(name.space, name.local) : value.getAttribute(name);
}
for (value in name) this.attr(value, name[value]);
return this;
}
return this.each(d3_selection_attr(name, value));
};
Expand Down

0 comments on commit b20c823

Please sign in to comment.