anyParentHasAttribute function
Return true if the element or any of its ancestors have an attribute.
It's used to handle lose focus (or blur) event for composite components. For example, MaterialAutoSuggestInput need close suggest popup when lose focus from the input, but not for the case when clicking the popup itself.
Implementation
bool anyParentHasAttribute(Element? target, String attribute) {
while (target != null) {
if (target.attributes.containsKey(attribute)) {
return true;
}
target = target.parent;
}
return false;
}