in src/focus-zone.ts [378:402]
function setActiveDescendant(from: HTMLElement | undefined, to: HTMLElement, directlyActivated = false) {
if (!to.id) {
to.setAttribute('id', uniqueId())
}
if (from && from !== to) {
from.removeAttribute(isActiveDescendantAttribute)
}
if (
!activeDescendantControl ||
(!directlyActivated && activeDescendantControl.getAttribute('aria-activedescendant') === to.id)
) {
// prevent active descendant callback from being called repeatedly if the same element is activated (e.g. via mousemove)
return
}
activeDescendantControl.setAttribute('aria-activedescendant', to.id)
container.setAttribute(hasActiveDescendantAttribute, to.id)
to.setAttribute(
isActiveDescendantAttribute,
directlyActivated ? activeDescendantActivatedDirectly : activeDescendantActivatedIndirectly
)
activeDescendantCallback?.(to, from, directlyActivated)
}