Skip to content

Latest commit

 

History

History
69 lines (40 loc) · 2.21 KB

shadow-focus.md

File metadata and controls

69 lines (40 loc) · 2.21 KB
layout tags
doc-api.html
internal, shadow-dom, global-service

ally.event.shadowFocus

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

Description

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();

Arguments

Returns

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

Throws

Event data

The event.detail property provides the following data:

Name Type Description
event.detail.active HTMLElement The actually focused element within the Shadow DOM.
event.detail.elements array of HTMLElement The complete focus ancestry
event.detail.hosts array of HTMLElement The ShadowHost ancestry of the active element.

Examples

Notes

Related resources

Contributing