isSuperselector method

bool isSuperselector(
  1. SimpleSelector other
)

Whether this is a superselector of other.

That is, whether this matches every element that other matches, as well as possibly additional elements.

Implementation

bool isSuperselector(SimpleSelector other) {
  if (this == other) return true;
  if (other is PseudoSelector && other.isClass) {
    var list = other.selector;
    if (list != null && _subselectorPseudos.contains(other.normalizedName)) {
      return list.components.every(
        (complex) =>
            complex.components.isNotEmpty &&
            complex.components.last.selector.components.any(
              (simple) => isSuperselector(simple),
            ),
      );
    }
  }
  return false;
}