interface HTMLElementForIE extends HTMLElement { msMatchesSelector : ( selector : string ) => boolean ; } export function closest ( element , query ) { if ( element && element . closest ) { return element . closest ( query ) ; } while ( element && ! ( element . matches || ( < HTMLElementForIE > element ) . msMatchesSelector ) . call ( element , query ) ) { element = element . parentElement ; } return element ; }