classedIs method

bool classedIs(
  1. String classes
)

Returns true if and only if the first (non-null) selected element has the specified classes.

selection.classedIs("foo"); // true, perhaps

This is generally useful only if you know the selection contains exactly one element.

Implementation

bool classedIs(String classes) {
  var names = classArray(classes);

  DOMTokenList? list;
  if ((list = node()?.classList) == null) return false;

  var i = -1, n = names.length;
  while (++i < n) {
    if (!list!.contains(names[i])) {
      return false;
    }
  }
  return true;
}