# API index
When creating web applications or UI widgets these modules may come in handy.
# Countering browser bugs
Every software has its problems - so do browsers. These utilities combat things browsers get wrong.
ally.fix.pointerFocusChildren(Internet Explorer 10 - 11)ally.fix.pointerFocusInput(Safari and Firefox on Mac OS X)ally.fix.pointerFocusParent(WebKit and old Blink)
# Extended :focus Styling
Sometimes :focus is not enough for communicating your application's intentions properly.
ally.style.focusSourceprovideshtml[focus-source="pointer|key|script"]ally.style.focusWithinpolyfills:focus-withinwith.ally-focus-within
# Altering browser focus behavior
While it's best to use standardized features and leave browsers to figure things out, specifications sometimes leave us hanging in limbo.
ally.maintain.disabledrenders elements inert to prevent any user interactionally.maintain.hiddensetsaria-hidden="true"on insignificant branchesally.maintain.tabFocustraps TAB focus in the tabsequence
# Finding elements
In order to work with focusable elements, we must first know which elements we're supposed to work with. See what does "focusable" mean? for a differentiation.
ally.query.firstTabbablefinds the first keyboard focusable elementally.query.focusablefinds all focusable elementsally.query.shadowHostsfinds all elements hosting aShadowRootally.query.tabbablefinds all keyboard focusable elements in DOM orderally.query.tabsequencefinds all keyboard focusable elements in Sequential Navigation Focus Order
# Element state
Unlike any other ally modules, these components do not take take options.context argument, but expect the element as first argument, allowing easy use in .filter(). See what does "focusable" mean? for a differentiation.
ally.is.activeElementreturns true if the element is the activeElement of its host context, i.e. its document, iFrame or ShadowHostally.is.disabledreturns true if the element is:disabledally.is.focusRelevantreturns true if the element is considered theoretically focusableally.is.focusablereturns true if the element is considered focusable by scriptally.is.onlyTabbablereturns true if the element is tabbable but not focusableally.is.shadowedreturns true if the element is the descendant of aShadowRootally.is.tabbablereturns true if the element is considered keyboard focusable ("tabbable")ally.is.validAreareturns true if the<area>element is properly used via<map>by an<img>ally.is.validTabindexreturns true if the element'stabindexattribute value is soundally.is.visiblereturns true if the element is rendered (but not necessarily visible in the viewport)
# Manipulating element state
Making up for missing or lacking DOM mutation APIs.
ally.element.blurshifts focus away from an elementally.element.disableddisables all elements, not only form controlsally.element.focusshifts focus to an element
# Reacting to element state
Especially when dealing with transitional user interfaces we need to know when an element can be safely focused.
ally.when.focusableexecutes a callback once an element fulfillsally.is.focusableand is visible in the viewportally.when.keyexecutes a callback when a given key has been pressedally.when.visibleAreaexecutes a callback once an element is visible in the viewport
# DOM traversal
Sometimes you need some DOM traversal utilities
ally.get.insignificantBranchesreturns an array containing the branches of the DOM that do contain any of the target elementsally.get.activeElementidentifies the element that has focus
# Values
ally.map.attributemaps WAI-ARIA states and propertiesally.map.keycodemaps control keys to readable names
# Developer modules
When creating libraries these modules may come in handy.
When you find yourself using one of these in your application code, we should talk about what you're trying to achieve and how we could do that as part of the library instead. Get in touch, file an issue explaining what you're trying to achieve!
# DOM traversal (extended)
Sometimes you need some DOM traversal utilities
ally.get.activeElementsidentifies theShadowHostancestry of the active elementally.get.insignificantBranchesally.get.focusRedirectTargetally.get.focusTargetally.get.parentsally.get.shadowHostParentsally.get.shadowHost
# Event dispatchers
Emitting events when there's no standardized equivalent
# Event listeners
Translate volatile events to stateful interfaces
ally.observe.interactionTypeobserves user interaction method to distinguish pointer and keyboard actionsally.observe.shadowMutationsregistersMutationObservers across nestedShadowRoots
# Contributor modules
When working on ally.js these modules may come in handy.
When you find yourself using one of these in your application or library code, we should talk about what you're trying to achieve and how we could do that as part of the library instead. Get in touch, file an issue explaining what you're trying to achieve!
::note
These modules are only available to be consumed via ES6, AMD or CommonJS directly, they are not exposed in the production bundle dist/ally.min.js.
:::
The internal tools are documented in a less accessible way to make it just a tiny bit harder for someone not working on ally to use them. This is intentional. The stability of these APIs is not guaranteed.