Skip to content

ally.js

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

🔗ally.fix.pointerFocusParent

This Browser Bug Workaround targets an issue in old Blink and WebKit causing focus (by MouseEvent and TouchEvent) to be given to the next parent element accepting focus, rather than the element the event was dispatched to.

🔗Description

Considering the following markup, clicking on the <a> element would focus the <div> instead:

<div tabindex="-1">
  <a href="http://example.org/">Hello World</a>
</div>

🔗Usage

// engage the workaround for the entire document
var handle = ally.fix.pointerFocusParent();
// disengage the workaround
handle.disengage();
// engage the workaround only for a sub-tree
var handle = ally.fix.pointerFocusParent({
  context: '#element-to-fix',
});

🔗Arguments

NameTypeDefaultDescription
context<selector>documentThe scope of the DOM in which to apply the fix. All elements of the collections are used.

🔗Returns

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

🔗Examples

🔗Example: ally.fix.pointerFocusParent Example

ally.fix.pointerFocusParent Example on jsbin.com

play with the example on jsbin.com or open the source document

🔗Notes

NOTE: Only engaged for WebKit (detected via via platform.js).

🔗Related resources

🔗Contributing