export const elementHasAncestor = ( element , ancestorNodeName , stopNodeName ? ) => { switch ( element ?. nodeName ) { case undefined : case stopNodeName ?. toUpperCase ( ) : return false ; case ancestorNodeName . toUpperCase ( ) : return true ; default : return elementHasAncestor ( element . parentElement , ancestorNodeName , stopNodeName ) ; } } ;