d3 selectAll 源代码

d3 selectAll Source code

我正在尝试了解 source code for d3 selectAll 我不明白下面我的评论后面的那一行。

我可以看到选择器字符串上有一个闭包,并且 this 在调用 d3_selectAll 时设置为节点,但是 [=12= 中的其他三个参数如何]消耗?

import "../core/array";
import "selection";

d3_selectionPrototype.selectAll = function(selector) {
  var subgroups = [],
      subgroup,
      node;

  selector = d3_selection_selectorAll(selector);




for (var j = -1, m = this.length; ++j < m;) {
    for (var group = this[j], i = -1, n = group.length; ++i < n;) {
      if (node = group[i]) {
        //***where are node.__data__, i, j consumed?***
        subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));
        subgroup.parentNode = node;
      }
    }
  }



return d3_selection(subgroups);
};

function d3_selection_selectorAll(selector) {
  return typeof selector === "function" ? selector : function() {
    return d3_selectAll(selector, this);
  };
}

这仅在子选择的上下文中相关,并在 documentation:

中进行了解释

The selector may also be specified as a function that returns an array of elements (or a NodeList), or the empty array if there are no matching elements. In this case, the specified selector is invoked in the same manner as other operator functions, being passed the current datum d and index i , with the this context as the current DOM element.

特别是,如果选择器不是函数,这些参数将被简单地忽略(最后的函数声明没有参数)。