anyParentHasTag function
Return true if the element or any of its ancestors have the given tag.
It's used to handle lose focus (or blur) event for composite components. For example, FilterBarComponent needs to enter summary mode when it loses focus, unless the focus is moving to one of the components it spawned.
Implementation
bool anyParentHasTag(Element? target, String componentTag) {
componentTag = componentTag.toLowerCase();
while (target != null) {
if (target.tagName.toLowerCase() == componentTag) {
return true;
}
target = target.parent;
}
return false;
}