Skip to content

ally.js

JavaScript library to help modern web applications with accessibility concerns by making accessibility simpler

🔗ally.event.shadowFocus

Observes focus changes within Shadow DOMs and emits shadow-focus CustomEvents.

🔗Usage

document.addEventListener('shadow-focus', function(event) {
  // event.detail.elements: complete focus ancestry (array of nodes)
  // event.detail.active: the actually focused element within the Shadow DOM
  // event.detail.hosts: the shadow host ancestry of the active element
}, false);

// start emitting shadow-focus
var handle = ally.event.shadowFocus();
// stop emitting shadow-focus
handle.disengage();

🔗Returns

A <global-service> interface, providing the handle.disengage() method to stop the service.

🔗Event data

The event.detail property provides the following data:

NameTypeDescription
event.detail.activeHTMLElementThe actually focused element within the Shadow DOM.
event.detail.elementsarray of HTMLElementThe complete focus ancestry
event.detail.hostsarray of HTMLElementThe ShadowHost ancestry of the active element.

🔗Related resources

🔗Contributing