license fileoverview export function closest ( element , selector ) { if ( element . closest ) { return element . closest ( selector ) ; } let el = element ; while ( el ) { if ( matches ( el , selector ) ) { return el ; } el = el . parentElement ; } return null ; } export function matches ( element , selector ) { const nativeMatches = element . matches || element . webkitMatchesSelector || ( element as any ) . msMatchesSelector ; return nativeMatches . call ( element , selector ) ; } param { Element } element export function estimateScrollWidth ( element ) { const htmlEl = element as HTMLElement ; if ( htmlEl . offsetParent !== null ) { return htmlEl . scrollWidth ; } const clone = htmlEl . cloneNode ( true ) as HTMLElement ; clone . style . setProperty ( 'position' , 'absolute' ) ; clone . style . setProperty ( 'transform' , 'translate(-9999px, -9999px)' ) ; document . documentElement . appendChild ( clone ) ; const scrollWidth = clone . scrollWidth ; document . documentElement . removeChild ( clone ) ; return scrollWidth ; }