querySelectorAll<T extends Element> method

ElementList<T> querySelectorAll<T extends Element>(
  1. String input
)
inherited

Finds all descendant elements of this document that match the specified group of selectors.

Unless your webpage contains multiple documents, the top-level querySelectorAll method behaves the same as this method, so you should use it instead to save typing a few characters.

selectors should be a string using CSS selector syntax.

var items = document.querySelectorAll('.itemClassName');

For details about CSS selector syntax, see the CSS selector specification.

Implementation

ElementList<T> querySelectorAll<T extends Element>(String input) {
  final selectorGroup = css.parseSelectorGroup(input);
  if (selectorGroup == null) {
    throw DomException._(
      DomException.SYNTAX,
      "Failed to execute 'querySelector' on 'Element': The provided selector is empty.",
    );
  }
  final result = <Element>[];
  _forEachElementInTree((element) {
    if (_matchesSelectorGroup(element, selectorGroup, null)) {
      result.add(element);
    }
  });
  return _FrozenElementList<T>._wrap(result);
}