getElementsWithAttributes function

List<Element> getElementsWithAttributes(
  1. String tag,
  2. Map<String, dynamic> matchAttributes
)

Selects elements from DOM with tag and matches attribute.

tag Type of tag for selection. matchAttributes Attributes to match in selection.

Implementation

List<Element> getElementsWithAttributes(
    String tag, Map<String, dynamic> matchAttributes) {
  var tags = (document.getElementsByTagName(tag)).whereType<Element>();
  return tags
      .where((e) => elementMatchesAttributes(e, matchAttributes))
      .toList();
}