export function getClosest ( elem , selector ) { for ( let node = elem ; node && node !== document . body ; node = node . parentElement ) { if ( node . matches ( selector ) ) return node ; } return null ; } export function getPopupContainer ( trigger ) { return getClosest ( trigger , '[data-popup-container]' ) || document . body ; }