equal
deleted
inserted
replaced
|
1 d3_selectionPrototype.property = function(name, value) { |
|
2 |
|
3 // If no value is specified, return the first value. |
|
4 if (arguments.length < 2) return this.node()[name]; |
|
5 |
|
6 function propertyNull() { |
|
7 delete this[name]; |
|
8 } |
|
9 |
|
10 function propertyConstant() { |
|
11 this[name] = value; |
|
12 } |
|
13 |
|
14 function propertyFunction() { |
|
15 var x = value.apply(this, arguments); |
|
16 if (x == null) delete this[name]; |
|
17 else this[name] = x; |
|
18 } |
|
19 |
|
20 return this.each(value == null |
|
21 ? propertyNull : (typeof value === "function" |
|
22 ? propertyFunction : propertyConstant)); |
|
23 }; |