ally.fix.pointerFocusParent

September 28, 2016 ยท View on GitHub

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="https://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.

Throws

Examples

@@@example /api/fix/pointer-focus-parent.example.html

pointerFocusParent example

@@@

Notes

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

Contributing