Skip to content

Latest commit

 

History

History
73 lines (45 loc) · 2.12 KB

pointer-focus-parent.md

File metadata and controls

73 lines (45 loc) · 2.12 KB
layout tags
doc-api.html
browser-fix, service, argument-options

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

Name Type Default Description
context <selector> document The 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

Notes

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

Related resources

Contributing