toolkit/javascript/d3/src/core/selection-property.js
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     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 };