text: d3_selectionPrototype.classed = function(name, value) {
    var re = new RegExp("(^|\\s+)" + d3.requote(name) + "(\\s+|$)", "g");
  
    // If no value is specified, return the first value.
    if (arguments.length < 2) {
      var node = this.node();
      if (c = node.classList) return c.contains(name);
      var c = node.className;
      re.lastIndex = 0;
      return re.test(c.baseVal != null ? c.baseVal : c);
    }
  
    function classedAdd() {
      if (c = this.classList) return c.add(name);
      var c = this.className,
          cb = c.baseVal != null,
          cv = cb ? c.baseVal : c;
      re.lastIndex = 0;
      if (!re.test(cv)) {
        cv = d3_collapse(cv + " " + name);
        if (cb) c.baseVal = cv;
        else this.className = cv;
      }
    }
  
    function classedRemove() {
      if (c = this.classList) return c.remove(name);
      var c = this.className,
          cb = c.baseVal != null,
          cv = cb ? c.baseVal : c;
      cv = d3_collapse(cv.replace(re, " "));
      if (cb) c.baseVal = cv;
      else this.className = cv;
    }
  
    function classedFunction() {
      (value.apply(this, arguments)
          ? classedAdd
          : classedRemove).call(this);
    }
  
    return this.each(typeof value === "function"
        ? classedFunction : value
        ? classedAdd
        : classedRemove);
  };
  