selectAll function

Selection selectAll([
  1. Union3<String, Iterable<Element?>, Object>? selector
])

Selects all elements that match the specified selector string.

final p = d4.selectAll("p".u31);

The elements will be selected in document order (top-to-bottom). If no elements in the document match the selector, or if the selector is null, returns an empty selection.

If the selector is not a string, instead selects the specified list of nodes; this is useful if you already have a reference to nodes, such as this.childNodes within an event listener or a global such as document.links. The nodes may instead be an iterable, or a pseudo-array such as a NodeList. For example, to color all links red:

d4.selectAll(document.links.u33).styleSet("color", "red".u22);

Implementation

Selection selectAll([Union3<String, Iterable<Element?>, Object>? selector]) {
  return selector == null
      ? createSelection([[]], root)
      : selector.split(
          (selector) => createSelection(
              [list(document.querySelectorAll(selector).u22)],
              [document.documentElement]),
          (iterable) => createSelection([list(iterable.u21)], root),
          (object) => createSelection([list(object.u22)], root),
        );
}