param element param className function findAncestor ( element , className ) { return findAncestorP ( element , e => hasClass ( e , className ) ) ; } param element param predicate function findAncestorP ( element , predicate ) { if ( element === null ) { return null ; } while ( ( element = element . parentElement ) && element && ! predicate ( element ) ) ; return element ; } function hasClass ( element , cls ) { return ( " " + element . className + " " ) . indexOf ( " " + cls + " " ) > - 1 ; } export { findAncestor , findAncestorP , hasClass } ;