propertySet method

Selection propertySet(
  1. String name,
  2. Union2<EachCallback<JSAny?>, JSAny?>? value
)

Sets the property with the specified name to the specified value on selected elements.

selection.propertySet("checked", true.toJS.u22);

If the value is a constant, then all elements are given the same property value; otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d), the current index (i), and the current group (nodes), with thisArg as the current DOM element (nodes[i]). The function’s return value is then used to set each element’s property. A null value will delete the specified property.

Implementation

Selection propertySet(
    String name, Union2<EachCallback<JSAny?>, JSAny?>? value) {
  return each(
    value?.split(
          (callback) => propertyFunction(name, callback),
          (value) => propertyConstant(name, value),
        ) ??
        propertyRemove(name),
  );
}