--- layout: doc-page.html --- # API concepts This document explains the concepts, structures and data types used in ally.js ## Function signatures By function signature we generally understand the combination of function name, arguments and return type. ally.js takes great care to provide consistent signatures across its components. Considering only a specific component, the generalized signatures may seem a bit over-engineered. But when considering the grander scheme the dogged application of the same concepts reduce guess-work on the API user's side. ### Single options argument The components ally.js provides usually accept a single argument, a so call options object. By enforcing this pattern, it is becomes immediately clear what the individual arguments are intended to do: ```js exampleWithoutOptions(document.body, '#gustav'); exampleWithOptions({ context: document.body, filter: '#gustav', }); ``` Most components will accept or even require an option called `context`. Depending on the component in question, this is either the scope of the DOM to operate in, or the element to operate on. There are components that *only* accept the `context` option, but retain the option argument signature for consistency. ### Failing silently and throwing errors When arguments passed to a function lead to a no-op ("no operation performed"), that function is required to fail silently. This means that it will simply return an empty set or `null`. However, when a function is passed arguments, or *not* passed required arguments, the function will throw a [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) to alert the API user to a possible issue in their code. ## Selector Many components work on the DOM. Components ingest elements identified by various `` types: * [CSS Selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) * [`HTMLElement`](https://developer.mozilla.org/en/docs/Web/API/HTMLElement) * array of [`HTMLElement`](https://developer.mozilla.org/en/docs/Web/API/HTMLElement) * [`NodeList`](https://developer.mozilla.org/en/docs/Web/API/NodeList) * [`HTMLCollection`](https://developer.mozilla.org/en/docs/Web/API/HTMLCollection) * [`jQuery`](https://api.jquery.com/jQuery/) instance ## Focus identification exceptions Modules dealing with the focus identity of elements (e.g. the `rules()` functions of `ally.is.focusable`, `ally.is.tabbable`, …) may accept an options object called `except` to customize the way focus identity is determined. | Name | Type | Default | Description | | ---- | ---- | ------- | ----------- | | flexbox | boolean | `false` | Prevent elements from being considered focus-relevant because of having Flexbox layout. | | scrollable | boolean | `false` | Prevent elements from being considered focus-relevant because of being scrollable. | | shadow | boolean | `false` | Prevent elements from being considered focus-relevant because of being a `ShadowHost`. | | disabled | boolean | `false` | Prevent elements from *not* being considered focusable because they're disabled (e.g. ``). | | visible | boolean | `false` | Prevent elements from *not* being considered focusable because they're hidden (e.g. ``). | | onlyFocusableBrowsingContext | boolean `false` | Prevent elements from *not* being considered focusable if their browsing context host element (e.g. `