All examples By author By category About

cpietsch

Local Variables

In response to mbostock's block: Local Variables and the Tweet I implemented a little variation having a .local(name[, value) method you can use on selections.

On set, the value is stored on the given element:

element.local("foo", value);

On get, the value is retrieved from given element, or the nearest ancestor that defines it:

var value = element.local("foo");