Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selection.prop as alias for property #37

Closed
gka opened this issue Aug 19, 2015 · 1 comment
Closed

Add selection.prop as alias for property #37

gka opened this issue Aug 19, 2015 · 1 comment

Comments

@gka
Copy link

gka commented Aug 19, 2015

I assume that selection.attr isn't named selection.attribute for a reason.
So why force everyone to write .property every time?

@mbostock
Copy link
Member

Well technically it refers to the interface Attr from W3C DOM Level 1. Also… there’s jQuery’s selection.attr method, but that’s more of a coincidence because D3 uses selection.style rather than selection.css.

But I can’t say whether this was truly intentional at the time, or if I was overly concerned about brevity. In general I prefer short words to abbreviations and acronyms, since the dropped letters are often arbitrary and difficult to guess. (For example, most UNIX commands.) Though you will find exceptions, like selection.attr and d3.xhr (which we agree should probably be named “request” instead, d3/d3-request#3)… and even the name “d3” itself!

If I thought about it too much, I’d probably be more inclined to rename it to selection.attribute and have selection.attr be the deprecated alias. But… I think it’s probably not worth making that change at this point, as “attr” is in wide usage.

Also, I like parsimony (and hence try to minimize aliases) so that code everywhere tends to be more consistent. If we introduce a selection.prop (or selection.attribute) alias, it’s one more thing for people to learn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants