anyParentHasClass function

bool anyParentHasClass(
  1. Element target,
  2. String className
)

Return true if the element or any of its ancestors have the given class.

Among other use cases, this can be helpful for handling nested popup scenarios. For example, BaseLensEdit needs to ignore clicks on targets that have ancestors of class material-popup-content when deciding whether a click counts as a click out (for exiting the popup).

Implementation

bool anyParentHasClass(Element target, String className) =>
    closestWithClass(target, className) != null;