export function elt ( tag , content ? , className ? , cssText ? ) { const e = document . createElement ( tag ) ; if ( className ) { e . className = className ; } if ( cssText ) { e . style . cssText = cssText ; } if ( typeof content === 'string' ) { e . appendChild ( document . createTextNode ( content ) ) ; } else if ( Array . isArray ( content ) ) { for ( let i = 0 ; i < content . length ; ++ i ) { e . appendChild ( content [ i ] ) ; } } return e ; } export type ListenerOptions = { capture : boolean ; passive : boolean ; } | boolean ; export function on ( el , event , listener , opts = false ) { el . addEventListener ( event , listener , opts ) ; } export function off ( el , event , listener , opts = false ) { el . removeEventListener ( event , listener , opts ) ; } export function removeChildren ( el ) { while ( el . firstChild ) { el . removeChild ( el . firstChild ) ; } return el ; } export function removeChildrenAndAdd ( parent , el ) { if ( Array . isArray ( el ) ) { removeChildren ( parent ) ; el . forEach ( ( e ) => parent . appendChild ( e ) ) ; return parent ; } else { return removeChildren ( parent ) . appendChild ( el ) ; } }