MCPcopy Create free account
hub / github.com/microsoft/SandDance / getActiveElementInfo

Function getActiveElementInfo

docs/app/js/sanddance-app.js:6723–6738  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

6721 }
6722}
6723function getActiveElementInfo(container) {
6724 let element = document.activeElement;
6725 const { scrollTop , selectionDirection , selectionEnd , selectionStart } = element;
6726 const activeElementInfo = {
6727 childPositions: [],
6728 scrollTop,
6729 selectionDirection,
6730 selectionEnd,
6731 selectionStart
6732 };
6733 while(element && element !== document.body && element !== container){
6734 activeElementInfo.childPositions.unshift(getChildPosition(element));
6735 element = element.parentElement;
6736 }
6737 if ((element === document.body || element === container) && activeElementInfo.childPositions.length) return activeElementInfo;
6738}
6739function getChildPosition(element) {
6740 let childPosition = 0;
6741 while(element = element.previousElementSibling)childPosition++;

Callers 1

presentMethod · 0.50

Calls 1

getChildPositionFunction · 0.70

Tested by

no test coverage detected