license param node export const isNodeElement = ( node ) : node is Element => { return node . nodeType === Node . ELEMENT_NODE ; } ; export type Constructor < T > = new ( ... args ) => T ; export function addHasRemoveClass ( element ) { return { addClass : ( className ) => { element . classList . add ( className ) ; } , removeClass : ( className ) => { element . classList . remove ( className ) ; } , hasClass : ( className ) => element . classList . contains ( className ) , } ; } let supportsPassive = false ; const fn = ( ) => { } ; const optionsBlock = { get passive ( ) { supportsPassive = true ; return false ; } } ; document . addEventListener ( 'x' , fn , optionsBlock ) ; document . removeEventListener ( 'x' , fn ) ; /**
 * Do event listeners suport the `passive` option?
 */ export const supportsPassiveEventListener = supportsPassive ; export const deepActiveElementPath = ( doc = window . document ) : Element [ ] => { let activeElement = doc . activeElement ; const path = [ ] ; if ( ! activeElement ) { return path ; } while ( activeElement ) { path . push ( activeElement ) ; if ( activeElement . shadowRoot ) { activeElement = activeElement . shadowRoot . activeElement ; } else { break ; } } return path ; } ; export const doesElementContainFocus = ( element ) : boolean => { const activePath = deepActiveElementPath ( ) ; if ( ! activePath . length ) { return false ; } const deepActiveElement = activePath [ activePath . length - 1 ] ; const focusEv = new Event ( 'check-if-focused' , { bubbles : true , composed : true } ) ; let composedPath = [ ] ; const listener = ( ev ) => { composedPath = ev . composedPath ( ) ; } ; document . body . addEventListener ( 'check-if-focused' , listener ) ; deepActiveElement . dispatchEvent ( focusEv ) ; document . body . removeEventListener ( 'check-if-focused' , listener ) ; return composedPath . indexOf ( element ) !== - 1 ; } ; export interface RippleInterface { startPress : ( e ? : Event ) => void ; endPress : ( ) => void ; startFocus : ( ) => void ; endFocus : ( ) => void ; startHover : ( ) => void ; endHover : ( ) => void ; }