license import { assert } from "./assertions" ; param node return function isDocumentRoot ( node ) { return node . nodeType === 11 || node . nodeType === 9 ; } param node return function isElement ( node ) { return node . nodeType === 1 ; } param node return function isText ( node ) { return node . nodeType === 3 ; } param node param root return function getAncestry ( node , root ) { const ancestry = [ ] ; let cur = node ; while ( cur !== root ) { const n = assert ( cur ) ; ancestry . push ( n ) ; cur = n . parentNode ; } return ancestry ; } param this returns const getRootNode = ( typeof Node !== "undefined" && ( Node as any ) . prototype . getRootNode ) || function ( this ) { let cur = this as Node ; let prev = cur ; while ( cur ) { prev = cur ; cur = cur . parentNode ; } return prev ; } ; param node returns function getActiveElement ( node ) { const root = getRootNode . call ( node ) ; return isDocumentRoot ( root ) ? root . activeElement : null ; } param node param root returns function getFocusedPath ( node , root ) { const activeElement = getActiveElement ( node ) ; if ( ! activeElement || ! node . contains ( activeElement ) ) { return [ ] ; } return getAncestry ( activeElement , root ) ; } param parentNode param node param referenceNode function moveBefore ( parentNode , node , referenceNode ) { const insertReferenceNode = node . nextSibling ; let cur = referenceNode ; while ( cur !== null && cur !== node ) { const next = cur . nextSibling ; parentNode . insertBefore ( cur , insertReferenceNode ) ; cur = next ; } } export { isElement , isText , getFocusedPath , moveBefore } ;