applying transfer to react app

This commit is contained in:
Tyler Koenig
2021-09-20 16:54:47 -04:00
parent 8819f31dd0
commit c612b7d702
37373 changed files with 3775588 additions and 2871 deletions
+6
View File
@@ -0,0 +1,6 @@
ie 11
edge >= 14
firefox >= 52
chrome >= 49
safari >= 10
node 10.0
+323
View File
@@ -0,0 +1,323 @@
# dom-accessibility-api changelog
## 0.5.7
### Patch Changes
- [#718](https://github.com/eps1lon/dom-accessibility-api/pull/718) [`6154760`](https://github.com/eps1lon/dom-accessibility-api/commit/61547602a7676167a65a893be53c3cf6b4e010b5) Thanks [@calebeby](https://github.com/calebeby)! - Remove implicit "document" role on `<body>` and add it to `<html>`
## 0.5.6
### Patch Changes
- [#666](https://github.com/eps1lon/dom-accessibility-api/pull/666) [`26ee73d`](https://github.com/eps1lon/dom-accessibility-api/commit/26ee73de9ad6fce27cde0d5ec53a2bc4a12bd879) Thanks [@eps1lon](https://github.com/eps1lon)! - Consider `<label />` when computing the accessible name of `<output />`
Given
```html
<label for="outputid">Output Label</label> <output id="outputid"></output>
```
Previously the accessible name of the `<output />` would ignore the `<label />`.
However, an [`<output />` is labelable](https://html.spec.whatwg.org/#the-output-element) and therefore the accessible name is now computed using `<label />` elements if they exists.
In this example the accessible name is `"Output Label"`.
## 0.5.5
### Patch Changes
- [#627](https://github.com/eps1lon/dom-accessibility-api/pull/627) [`0485441`](https://github.com/eps1lon/dom-accessibility-api/commit/0485441e68cf728596d7140bdff2ac13280eefab) Thanks [@eps1lon](https://github.com/eps1lon)! - Ensure certain babel helpers aren't required
Source:
```diff
-const [item] = list;
+const item = list[0];
```
Transpiled:
```diff
-var _trim$split = list.trim().split(" "),
-_trim$split2 = _slicedToArray(_trim$split, 1),
-item = _trim$split2[0]
+var item = list[0];
```
* [#629](https://github.com/eps1lon/dom-accessibility-api/pull/629) [`383bdb6`](https://github.com/eps1lon/dom-accessibility-api/commit/383bdb616c00105474c8607dd9e5aab4deaff7ed) Thanks [@eps1lon](https://github.com/eps1lon)! - Use label attribute for naming of `<optgroup>` elements.
Given
```jsx
<select>
<optgroup label="foo">
<option value="1">bar</option>
</optgroup>
</select>
```
Previously the `<optgroup />` would not have an accessible name.
Though [2D in `accname` 1.2](https://www.w3.org/TR/accname-1.2/) could be interpreted to use the `label` attribute:
> Otherwise, if the current node's native markup provides an attribute (e.g. title) or element (e.g. HTML label) that defines a text alternative, return that alternative [...]
This was confirmed in NVDA + FireFox.
## 0.5.4
### Patch Changes
- [`3866289`](https://github.com/eps1lon/dom-accessibility-api/commit/3866289a6ad92b73a8c031a2983165e1b1f2b24c) [#442](https://github.com/eps1lon/dom-accessibility-api/pull/442) Thanks [@geoffrich](https://github.com/geoffrich)! - Correctly determine accessible name when element contains a slot.
Previously, computing the accessible name would only examine child nodes. However, content placed in a slot is is an assigned node, not a child node.
If you have a custom element `custom-button` with a slot:
```html
<button><slot></slot></button>
<!-- accname of inner <button> is 'Custom name' (previously '') -->
<custom-button>Custom name</custom-button>
```
If you have a custom element `custom-button-default` with default content in the slot:
```html
<button><slot>Default name</slot></button>
<!-- accname of inner <button> is 'Custom name' (previously 'Default name') -->
<custom-button-default>Custom name</custom-button-default>
<!-- accname of inner <button> is 'Default name' (previously 'Default name') -->
<custom-button-default></custom-button-default>
```
This is not currently defined in the accname spec but reflects current browser behavior.
## 0.5.3
### Patch Changes
- [`76e8f93`](https://github.com/eps1lon/dom-accessibility-api/commit/76e8f93ccd8d6d3464d1b362a22163c501b9ea37) [#430](https://github.com/eps1lon/dom-accessibility-api/pull/430) Thanks [@ckundo](https://github.com/ckundo)! - Maintain `img` role for `img` with missing `alt` attribute.
Previously `<img />` would be treated the same as `<img alt />`.
`<img />` is now treated as `role="img"` [as specified](https://w3c.github.io/html-aam/#el-img-empty-alt).
* [`96d4438`](https://github.com/eps1lon/dom-accessibility-api/commit/96d443855b897fccb9fa09d5f595c502b23e6cf9) [#436](https://github.com/eps1lon/dom-accessibility-api/pull/436) Thanks [@eps1lon](https://github.com/eps1lon)! - Resolve presentational role conflicts when global WAI-ARIA states or properties (ARIA attributes) are used.
`<img alt="" />` used to have no role.
[By spec](https://w3c.github.io/html-aam/#el-img-empty-alt) it should have `role="presentation"` with no ARIA attributes or `role="img"` [otherwise](https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none).
## 0.5.2
### Patch Changes
- [`03273b7`](https://github.com/eps1lon/dom-accessibility-api/commit/03273b7d91a156a6dd9c727293a491cd2d1f02f1) [#406](https://github.com/eps1lon/dom-accessibility-api/pull/406) Thanks [@eps1lon](https://github.com/eps1lon)! - Fix various issues for input types `submit`, `reset` and `image`
Prefer input `value` when `type` is `reset` or `submit`:
```diff
<input type="submit" value="Submit values">
-// accessible name: "Submit"
+// accessible name: "Submit values"
<input type="reset" value="Reset form">
-// accessible name: "Reset"
+// accessible name: "Reset form"
```
For input `type` `image` consider `alt` attribute or fall back to `"Submit query"`.
## 0.5.1
### Patch Changes
- [`fcc66ae`](https://github.com/eps1lon/dom-accessibility-api/commit/fcc66aef833b8c7546921800e09cbb2096ef9601) [#394](https://github.com/eps1lon/dom-accessibility-api/pull/394) Thanks [@marcosvega91](https://github.com/marcosvega91)! - Ignore `title` attribute if it is empty.
Previously `<button title="">Hello, Dave!</button>` would wrongly compute an empty name.
## 0.5.0
### Minor Changes
- [`9e46c51`](https://github.com/eps1lon/dom-accessibility-api/commit/9e46c51b51993c65237efd4b0d046f1a35c3e76a) [#380](https://github.com/eps1lon/dom-accessibility-api/pull/380) Thanks [@eps1lon](https://github.com/eps1lon)! - **BREAKING CHANGE**
Ignore `::before` and `::after` by default.
This was necessary to prevent excessive warnings in `jsdom@^16.4.0`.
If you use this package in a browser that supports the second argument of `window.getComputedStyle` you can set the `computedStyleSupportsPseudoElements` option to true:
```ts
computeAccessibleName(element, {
computedStyleSupportsPseudoElements: true
});
computeAccessibleDescription(element, {
computedStyleSupportsPseudoElements: true
});
```
If you pass a custom implementation of `getComputedStyle` then this option defaults to `true`.
The following two calls are equivalent:
```ts
computeAccessibleName(element, {
computedStyleSupportsPseudoElements: true
});
computeAccessibleName(element, {
getComputedStyle: (element, pseudoElement) => {
// custom implementation
}
});
```
### Patch Changes
- [`5db24b1`](https://github.com/eps1lon/dom-accessibility-api/commit/5db24b1fa0c75a5914526de1c58da54db294f405) [#368](https://github.com/eps1lon/dom-accessibility-api/pull/368) Thanks [@eps1lon](https://github.com/eps1lon)! - Use `localName` to determine elements instead of `tagName`.
## 0.4.7
### Patch Changes
- [`d6c4455`](https://github.com/eps1lon/dom-accessibility-api/commit/d6c44558250e898caa68e7b3eaa2f4d505078b3e) [#352](https://github.com/eps1lon/dom-accessibility-api/pull/352) Thanks [@eps1lon](https://github.com/eps1lon)! - Support native labels in IE 11
Also affects Edge < 18 and Firefox < 56.
## 0.4.6
### Patch Changes
- [`85f0032`](https://github.com/eps1lon/dom-accessibility-api/commit/85f0032e0ec9203df7e4e5d0c3c8a206ac1968c1) [#324](https://github.com/eps1lon/dom-accessibility-api/pull/324) Thanks [@juanca](https://github.com/juanca)! - Consider `<title>` for the name of its `<svg>` element.
* [`f7c1981`](https://github.com/eps1lon/dom-accessibility-api/commit/f7c19812307e8847dbe1b678a3bafdc6dbf7f23b) [#288](https://github.com/eps1lon/dom-accessibility-api/pull/288) Thanks [@eps1lon](https://github.com/eps1lon)! - Drop node 13 support
We only stopped testing. Probability of breakage should be very low.
**New policy**:
> Only [active node versions](https://nodejs.org/en/about/releases/) are supported.
> Inactive node versions can stop working in a SemVer MINOR release.
- [`fa53c51`](https://github.com/eps1lon/dom-accessibility-api/commit/fa53c510d8aab6cf3561c91949f1df3a52a500a8) [#210](https://github.com/eps1lon/dom-accessibility-api/pull/210) Thanks [@eps1lon](https://github.com/eps1lon)! - Implement accessbile description computation
```ts
import { computeAccessibleDescription } from "dom-accessibility-api";
const description = computeAccessibleDescription(element);
```
Warning: It always considers `title` attributes if the description is empty.
Even if the `title` attribute was already used for the accessible name.
This is fails a web-platform-test.
The other failing test is due to `aria-label` being ignored for the description which is correct by spec.
It's likely an issue with wpt.
The other tests are passing (13/15).
## 0.4.5
### Patch Changes
- [`d668f72`](https://github.com/eps1lon/dom-accessibility-api/commit/d668f724aeb42cb71d720e0acd3518a03bbbee6e) [#273](https://github.com/eps1lon/dom-accessibility-api/pull/273) Thanks [@eps1lon](https://github.com/eps1lon)! - fix: Concatenate text nodes without space
Fixes `<h1>Hello {name}!</h1>` in `react` computing `"Hello name !"` instead of `Hello name!`.
## 0.4.4
### Patch Changes
- [`e79f620`](https://github.com/eps1lon/dom-accessibility-api/commit/e79f6209667b3b2de656a73dec0eea37c65d48a9) [#208](https://github.com/eps1lon/dom-accessibility-api/pull/208) Thanks [@eps1lon](https://github.com/eps1lon)! - Add support for node 14
* [`2c6a23b`](https://github.com/eps1lon/dom-accessibility-api/commit/2c6a23b3ec3e514d7db631e393749fac0ab33b5b) [#200](https://github.com/eps1lon/dom-accessibility-api/pull/200) Thanks [@eps1lon](https://github.com/eps1lon)! - Add `module` field
- [`737dfae`](https://github.com/eps1lon/dom-accessibility-api/commit/737dfae2b88a4ce94d59144a6aabf69f0a671edc) [#234](https://github.com/eps1lon/dom-accessibility-api/pull/234) Thanks [@willamzv](https://github.com/willamzv)! - Consider `<legend>` for the name of its `<fieldset>` element.
```html
<fieldset>
<legend><em>my</em> fieldset</legend>
</fieldset>
```
Computing the name for this fieldset would've returned an empty string previously. It now correctly computes `my fieldset` following the [accessible name computation for `fieldset` elements](https://w3c.github.io/html-aam/#fieldset-and-legend-elements)
* [`969da7d`](https://github.com/eps1lon/dom-accessibility-api/commit/969da7d454b3d83dc7259d910f40e7e16a6eb560) [#240](https://github.com/eps1lon/dom-accessibility-api/pull/240) Thanks [@eps1lon](https://github.com/eps1lon)! - Reduce over-transpilation
Switched from
- `for-of` to `.forEach` or a basic `for` loop
- `array.push(...otherArray)` to `push.apply(array, otherArray)`
This removed a bunch of babel junk that wasn't needed.
- [`d578329`](https://github.com/eps1lon/dom-accessibility-api/commit/d5783292ca49ae947bd95559030aa2c93c04565f) [#248](https://github.com/eps1lon/dom-accessibility-api/pull/248) Thanks [@eps1lon](https://github.com/eps1lon)! - Consider `<caption>` for the name of its `<table>` element.
```html
<table>
<caption>
<em>my</em>
table
</caption>
</table>
```
Computing the name for this table would've returned an empty string previously. It now correctly computes `my table` following the [accessible name computation for `table` elements](https://w3c.github.io/html-aam/#table-element)
* [`f1b2bd0`](https://github.com/eps1lon/dom-accessibility-api/commit/f1b2bd0434cafe65812acfb0e3a2942309eb9726) [#237](https://github.com/eps1lon/dom-accessibility-api/pull/237) Thanks [@eps1lon](https://github.com/eps1lon)! - Use nodeType and tagName for element type checks
## 0.4.3
### Patch Changes
- [`b421d9e`](https://github.com/eps1lon/dom-accessibility-api/commit/b421d9e9709adf0f72e09cb5d7ea2a32ceefd8eb) [#168](https://github.com/eps1lon/dom-accessibility-api/pull/168) Thanks [@eps1lon](https://github.com/eps1lon)! - fix: Use relative paths in exports field
Fixes a crash when using ES modules in Node.
## 0.4.2
### Minor Changes
- [`0897630`](https://github.com/eps1lon/dom-accessibility-api/commit/0897630862d608a9ca22e9799bb30b37e1032afa) [#155](https://github.com/eps1lon/dom-accessibility-api/pull/155) - Publish version using ES6 modules allongside current CommonJS modules
## 0.4.1
### Patch Changes
- [`63c119f`](https://github.com/eps1lon/dom-accessibility-api/commit/63c119f388d4e0f121320d75c4ec6fe334d8f370) [#147](https://github.com/eps1lon/dom-accessibility-api/pull/147) Thanks [@eps1lon](https://github.com/eps1lon)! - Deploy all 0.4.0 changes
## 0.4.0
### Minor Changes
- [`e80a1fb`](https://github.com/eps1lon/dom-accessibility-api/commit/e80a1fb32c136539a46007a64ef8c998855080a1) [#141](https://github.com/eps1lon/dom-accessibility-api/pull/141) Thanks [@eps1lon](https://github.com/eps1lon)! - Support ES5 environments
### Patch Changes
- [`bd41c2d`](https://github.com/eps1lon/dom-accessibility-api/commit/bd41c2d3dec9c27e178b65bbe226d3c7adef0678) [#143](https://github.com/eps1lon/dom-accessibility-api/pull/143) Thanks [@eps1lon](https://github.com/eps1lon)! - fix: support `<label for>` for `<select>` and `<textarea>`
## 0.3.0
### Minor Changes
- 7f1ada0: Internal polish
## 0.2.0
### Minor Changes
- eb86842: Add option to mock window.getComputedStyle
This option has two use cases in mind:
1. fake the style and assume everything is visible.
This increases performance (window.getComputedStyle) is expensive) by not distinguishing between various levels of visual impairments. If one can't see the name with a screen reader then neither will a sighted user
2. Wrap a cache provider around `window.getComputedStyle`. We don't implement any because the returned `CSSStyleDeclaration` is only live in a browser. `jsdom` does not implement live declarations.
### Bug Fixes
- Fix test name_heading-combobox ([#16](https://github.com/eps1lon/dom-accessibility-api/issues/16)) ([e969395](https://github.com/eps1lon/dom-accessibility-api/commit/e969395d8da637862993aeee0b86f379342d56f2))
### Features
- **name:** Consider prohibited naming ([#19](https://github.com/eps1lon/dom-accessibility-api/issues/19)) ([6692d6b](https://github.com/eps1lon/dom-accessibility-api/commit/6692d6bd86030da9b340b0895f623394b21e2656))
- Consider all cases of "name from content" ([#13](https://github.com/eps1lon/dom-accessibility-api/issues/13)) ([835cb76](https://github.com/eps1lon/dom-accessibility-api/commit/835cb76e7c1dd577af1fa891ad849385e58fcd56))
- Consider content from before and after pseudo elements ([#5](https://github.com/eps1lon/dom-accessibility-api/issues/5)) ([0987426](https://github.com/eps1lon/dom-accessibility-api/commit/0987426734cc7b980a8edf39435820a24ea2a162))
- Fork elementToRole from aria-query ([#7](https://github.com/eps1lon/dom-accessibility-api/issues/7)) ([fe4fab5](https://github.com/eps1lon/dom-accessibility-api/commit/fe4fab57786324705c4ac4434de8aabd3e7bbc09))
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Sebastian Silbermann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+222
View File
@@ -0,0 +1,222 @@
# dom-accessibility-api
[![npm version](https://badge.fury.io/js/dom-accessibility-api.svg)](https://badge.fury.io/js/dom-accessibility-api)
[![Build Status](https://dev.azure.com/silbermannsebastian/dom-accessibility-api/_apis/build/status/eps1lon.dom-accessibility-api?branchName=main)](https://dev.azure.com/silbermannsebastian/dom-accessibility-api/_build/latest?definitionId=6&branchName=main)
![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/silbermannsebastian/dom-accessibility-api/6)
Computes the accessible name or description of a given DOM Element.
https://w3c.github.io/accname/ implemented in JavaScript for testing.
```bash
$ yarn add dom-accessibility-api
```
```js
import {
computeAccessibleName,
computeAccessibleDescription,
} from "dom-accessibility-api";
```
I'm not an editor of any of the referenced specs (nor very experience with using them) so if you got any insights, something catches
your eye please open an issue.
## Supported environments
**WARNING**: Only [active node versions](https://nodejs.org/en/about/releases/) are supported.
Inactive node versions can stop working in a SemVer MINOR release.
```bash
ie 11
edge >= 14
firefox >= 52
chrome >= 49
safari >= 10
node 10.0
```
or check the published `.browserslistrc`
## progress
Using https://github.com/web-platform-tests/wpt. Be sure to init submodules when
cloning. See [the test readme](/tests/README.md) for more info about the test setup.
### browser (Chrome)
153/159
### jsdom
<details>
<summary>report 138/159 passing of which 15 are due `::before { content }`, one might be a wrong test, 5 are pathological </summary>
```bash
web-platform-tests
accname
[expected fail] description_1.0_combobox-focusable-manual.html
[expected fail] description_from_content_of_describedby_element-manual.html
✓ description_link-with-label-manual.html
✓ description_test_case_557-manual.html
✓ description_test_case_664-manual.html
✓ description_test_case_665-manual.html
✓ description_test_case_666-manual.html
✓ description_test_case_772-manual.html
✓ description_test_case_773-manual.html
✓ description_test_case_774-manual.html
✓ description_test_case_838-manual.html
✓ description_test_case_broken_reference-manual.html
✓ description_test_case_one_valid_reference-manual.html
✓ description_title-same-element-manual.html
✓ name_1.0_combobox-focusable-alternative-manual.html
✓ name_1.0_combobox-focusable-manual.html
✓ name_checkbox-label-embedded-combobox-manual.html
✓ name_checkbox-label-embedded-listbox-manual.html
✓ name_checkbox-label-embedded-menu-manual.html
✓ name_checkbox-label-embedded-select-manual.html
✓ name_checkbox-label-embedded-slider-manual.html
✓ name_checkbox-label-embedded-spinbutton-manual.html
✓ name_checkbox-label-embedded-textbox-manual.html
✓ name_checkbox-label-multiple-label-alternative-manual.html
✓ name_checkbox-label-multiple-label-manual.html
✓ name_checkbox-title-manual.html
✓ name_file-label-embedded-combobox-manual.html
✓ name_file-label-embedded-menu-manual.html
✓ name_file-label-embedded-select-manual.html
✓ name_file-label-embedded-slider-manual.html
✓ name_file-label-embedded-spinbutton-manual.html
[expected fail] name_file-label-inline-block-elements-manual.html
[expected fail] name_file-label-inline-block-styles-manual.html
✓ name_file-label-inline-hidden-elements-manual.html
✓ name_file-label-owned-combobox-manual.html
✓ name_file-label-owned-combobox-owned-listbox-manual.html
✓ name_file-title-manual.html
✓ name_from_content-manual.html
✓ name_from_content_of_label-manual.html
✓ name_from_content_of_labelledby_element-manual.html
✓ name_from_content_of_labelledby_elements_one_of_which_is_hidden-manual.html
✓ name_heading-combobox-focusable-alternative-manual.html
✓ name_image-title-manual.html
✓ name_link-mixed-content-manual.html
✓ name_link-with-label-manual.html
✓ name_password-label-embedded-combobox-manual.html
✓ name_password-label-embedded-menu-manual.html
✓ name_password-label-embedded-select-manual.html
✓ name_password-label-embedded-slider-manual.html
✓ name_password-label-embedded-spinbutton-manual.html
✓ name_password-title-manual.html
✓ name_radio-label-embedded-combobox-manual.html
✓ name_radio-label-embedded-menu-manual.html
✓ name_radio-label-embedded-select-manual.html
✓ name_radio-label-embedded-slider-manual.html
✓ name_radio-label-embedded-spinbutton-manual.html
✓ name_radio-title-manual.html
✓ name_test_case_539-manual.html
✓ name_test_case_540-manual.html
✓ name_test_case_541-manual.html
✓ name_test_case_543-manual.html
✓ name_test_case_544-manual.html
✓ name_test_case_545-manual.html
✓ name_test_case_546-manual.html
✓ name_test_case_547-manual.html
✓ name_test_case_548-manual.html
✓ name_test_case_549-manual.html
✓ name_test_case_550-manual.html
✓ name_test_case_551-manual.html
[expected fail] name_test_case_552-manual.html
[expected fail] name_test_case_553-manual.html
✓ name_test_case_556-manual.html
✓ name_test_case_557-manual.html
✓ name_test_case_558-manual.html
✓ name_test_case_559-manual.html
✓ name_test_case_560-manual.html
✓ name_test_case_561-manual.html
✓ name_test_case_562-manual.html
✓ name_test_case_563-manual.html
✓ name_test_case_564-manual.html
✓ name_test_case_565-manual.html
✓ name_test_case_566-manual.html
✓ name_test_case_596-manual.html
✓ name_test_case_597-manual.html
✓ name_test_case_598-manual.html
✓ name_test_case_599-manual.html
✓ name_test_case_600-manual.html
✓ name_test_case_601-manual.html
✓ name_test_case_602-manual.html
✓ name_test_case_603-manual.html
✓ name_test_case_604-manual.html
✓ name_test_case_605-manual.html
✓ name_test_case_606-manual.html
✓ name_test_case_607-manual.html
✓ name_test_case_608-manual.html
✓ name_test_case_609-manual.html
✓ name_test_case_610-manual.html
✓ name_test_case_611-manual.html
✓ name_test_case_612-manual.html
✓ name_test_case_613-manual.html
✓ name_test_case_614-manual.html
✓ name_test_case_615-manual.html
✓ name_test_case_616-manual.html
✓ name_test_case_617-manual.html
✓ name_test_case_618-manual.html
✓ name_test_case_619-manual.html
✓ name_test_case_620-manual.html
✓ name_test_case_621-manual.html
[expected fail] name_test_case_659-manual.html
[expected fail] name_test_case_660-manual.html
[expected fail] name_test_case_661-manual.html
[expected fail] name_test_case_662-manual.html
[expected fail] name_test_case_663a-manual.html
✓ name_test_case_721-manual.html
✓ name_test_case_723-manual.html
✓ name_test_case_724-manual.html
✓ name_test_case_725-manual.html
✓ name_test_case_726-manual.html
✓ name_test_case_727-manual.html
✓ name_test_case_728-manual.html
✓ name_test_case_729-manual.html
✓ name_test_case_730-manual.html
✓ name_test_case_731-manual.html
✓ name_test_case_733-manual.html
✓ name_test_case_734-manual.html
✓ name_test_case_735-manual.html
✓ name_test_case_736-manual.html
✓ name_test_case_737-manual.html
✓ name_test_case_738-manual.html
✓ name_test_case_739-manual.html
✓ name_test_case_740-manual.html
✓ name_test_case_741-manual.html
✓ name_test_case_742-manual.html
✓ name_test_case_743-manual.html
✓ name_test_case_744-manual.html
✓ name_test_case_745-manual.html
✓ name_test_case_746-manual.html
✓ name_test_case_747-manual.html
✓ name_test_case_748-manual.html
✓ name_test_case_749-manual.html
✓ name_test_case_750-manual.html
✓ name_test_case_751-manual.html
✓ name_test_case_752-manual.html
[expected fail] name_test_case_753-manual.html
[expected fail] name_test_case_754-manual.html
[expected fail] name_test_case_755-manual.html
[expected fail] name_test_case_756-manual.html
[expected fail] name_test_case_757-manual.html
[expected fail] name_test_case_758-manual.html
[expected fail] name_test_case_759-manual.html
[expected fail] name_test_case_760-manual.html
[expected fail] name_test_case_761-manual.html
[expected fail] name_test_case_762-manual.html
✓ name_text-label-embedded-combobox-manual.html
✓ name_text-label-embedded-menu-manual.html
✓ name_text-label-embedded-select-manual.html
✓ name_text-label-embedded-slider-manual.html
✓ name_text-label-embedded-spinbutton-manual.html
✓ name_text-title-manual.html
```
</details>
## missing
- visibility context (inherited but can reappear; currently reappearing wont't work)
+9
View File
@@ -0,0 +1,9 @@
import { ComputeTextAlternativeOptions } from "./accessible-name-and-description";
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_description
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export declare function computeAccessibleDescription(root: Element, options?: ComputeTextAlternativeOptions): string;
//# sourceMappingURL=accessible-description.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"accessible-description.d.ts","sourceRoot":"","sources":["../sources/accessible-description.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,6BAA6B,EAC7B,MAAM,mCAAmC,CAAC;AAG3C;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,6BAAkC,GACzC,MAAM,CAqBR"}
+41
View File
@@ -0,0 +1,41 @@
"use strict";
exports.__esModule = true;
exports.computeAccessibleDescription = computeAccessibleDescription;
var _accessibleNameAndDescription = require("./accessible-name-and-description");
var _util = require("./util");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_description
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
function computeAccessibleDescription(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var description = (0, _util.queryIdRefs)(root, "aria-describedby").map(function (element) {
return (0, _accessibleNameAndDescription.computeTextAlternative)(element, _objectSpread(_objectSpread({}, options), {}, {
compute: "description"
}));
}).join(" "); // TODO: Technically we need to make sure that node wasn't used for the accessible name
// This causes `description_1.0_combobox-focusable-manual` to fail
//
// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation
// says for so many elements to use the `title` that we assume all elements are considered
if (description === "") {
var title = root.getAttribute("title");
description = title === null ? "" : title;
}
return description;
}
//# sourceMappingURL=accessible-description.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-description.ts"],"names":["computeAccessibleDescription","root","options","description","map","element","compute","join","title","getAttribute"],"mappings":";;;;;AAAA;;AAIA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,4BAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;AACT,MAAIC,WAAW,GAAG,uBAAYF,IAAZ,EAAkB,kBAAlB,EAChBG,GADgB,CACZ,UAACC,OAAD,EAAa;AACjB,WAAO,0DAAuBA,OAAvB,kCACHH,OADG;AAENI,MAAAA,OAAO,EAAE;AAFH,OAAP;AAIA,GANgB,EAOhBC,IAPgB,CAOX,GAPW,CAAlB,CADS,CAUT;AACA;AACA;AACA;AACA;;AACA,MAAIJ,WAAW,KAAK,EAApB,EAAwB;AACvB,QAAMK,KAAK,GAAGP,IAAI,CAACQ,YAAL,CAAkB,OAAlB,CAAd;AACAN,IAAAA,WAAW,GAAGK,KAAK,KAAK,IAAV,GAAiB,EAAjB,GAAsBA,KAApC;AACA;;AAED,SAAOL,WAAP;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { queryIdRefs } from \"./util\";\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_description\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleDescription(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tlet description = queryIdRefs(root, \"aria-describedby\")\n\t\t.map((element) => {\n\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t...options,\n\t\t\t\tcompute: \"description\",\n\t\t\t});\n\t\t})\n\t\t.join(\" \");\n\n\t// TODO: Technically we need to make sure that node wasn't used for the accessible name\n\t// This causes `description_1.0_combobox-focusable-manual` to fail\n\t//\n\t// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation\n\t// says for so many elements to use the `title` that we assume all elements are considered\n\tif (description === \"\") {\n\t\tconst title = root.getAttribute(\"title\");\n\t\tdescription = title === null ? \"\" : title;\n\t}\n\n\treturn description;\n}\n"],"file":"accessible-description.js"}
+35
View File
@@ -0,0 +1,35 @@
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { computeTextAlternative } from "./accessible-name-and-description.mjs";
import { queryIdRefs } from "./util.mjs";
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_description
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export function computeAccessibleDescription(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var description = queryIdRefs(root, "aria-describedby").map(function (element) {
return computeTextAlternative(element, _objectSpread(_objectSpread({}, options), {}, {
compute: "description"
}));
}).join(" "); // TODO: Technically we need to make sure that node wasn't used for the accessible name
// This causes `description_1.0_combobox-focusable-manual` to fail
//
// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation
// says for so many elements to use the `title` that we assume all elements are considered
if (description === "") {
var title = root.getAttribute("title");
description = title === null ? "" : title;
}
return description;
}
//# sourceMappingURL=accessible-description.mjs.map
@@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-description.ts"],"names":["computeTextAlternative","queryIdRefs","computeAccessibleDescription","root","options","description","map","element","compute","join","title","getAttribute"],"mappings":";;;;;;AAAA,SACCA,sBADD,QAGO,uCAHP;AAIA,SAASC,WAAT,QAA4B,YAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,4BAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;AACT,MAAIC,WAAW,GAAGJ,WAAW,CAACE,IAAD,EAAO,kBAAP,CAAX,CAChBG,GADgB,CACZ,UAACC,OAAD,EAAa;AACjB,WAAOP,sBAAsB,CAACO,OAAD,kCACzBH,OADyB;AAE5BI,MAAAA,OAAO,EAAE;AAFmB,OAA7B;AAIA,GANgB,EAOhBC,IAPgB,CAOX,GAPW,CAAlB,CADS,CAUT;AACA;AACA;AACA;AACA;;AACA,MAAIJ,WAAW,KAAK,EAApB,EAAwB;AACvB,QAAMK,KAAK,GAAGP,IAAI,CAACQ,YAAL,CAAkB,OAAlB,CAAd;AACAN,IAAAA,WAAW,GAAGK,KAAK,KAAK,IAAV,GAAiB,EAAjB,GAAsBA,KAApC;AACA;;AAED,SAAOL,WAAP;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { queryIdRefs } from \"./util\";\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_description\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleDescription(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tlet description = queryIdRefs(root, \"aria-describedby\")\n\t\t.map((element) => {\n\t\t\treturn computeTextAlternative(element, {\n\t\t\t\t...options,\n\t\t\t\tcompute: \"description\",\n\t\t\t});\n\t\t})\n\t\t.join(\" \");\n\n\t// TODO: Technically we need to make sure that node wasn't used for the accessible name\n\t// This causes `description_1.0_combobox-focusable-manual` to fail\n\t//\n\t// https://www.w3.org/TR/html-aam-1.0/#accessible-name-and-description-computation\n\t// says for so many elements to use the `title` that we assume all elements are considered\n\tif (description === \"\") {\n\t\tconst title = root.getAttribute(\"title\");\n\t\tdescription = title === null ? \"\" : title;\n\t}\n\n\treturn description;\n}\n"],"file":"accessible-description.mjs"}
@@ -0,0 +1,20 @@
/**
* interface for an options-bag where `window.getComputedStyle` can be mocked
*/
export interface ComputeTextAlternativeOptions {
compute?: "description" | "name";
/**
* Set to true if window.computedStyle supports the second argument.
* This should be false in JSDOM. Otherwise JSDOM will log console errors.
*/
computedStyleSupportsPseudoElements?: boolean;
getComputedStyle?: typeof window.getComputedStyle;
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te
* @param root
* @param [options]
* @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export declare function computeTextAlternative(root: Element, options?: ComputeTextAlternativeOptions): string;
//# sourceMappingURL=accessible-name-and-description.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"accessible-name-and-description.d.ts","sourceRoot":"","sources":["../sources/accessible-name-and-description.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC7C,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACjC;;;OAGG;IACH,mCAAmC,CAAC,EAAE,OAAO,CAAC;IAC9C,gBAAgB,CAAC,EAAE,OAAO,MAAM,CAAC,gBAAgB,CAAC;CAClD;AA6RD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,6BAAkC,GACzC,MAAM,CAgWR"}
@@ -0,0 +1,599 @@
"use strict";
exports.__esModule = true;
exports.computeTextAlternative = computeTextAlternative;
var _array = _interopRequireDefault(require("./polyfills/array.from"));
var _SetLike = _interopRequireDefault(require("./polyfills/SetLike"));
var _util = require("./util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* implements https://w3c.github.io/accname/
*/
/**
*
* @param {string} string -
* @returns {FlatString} -
*/
function asFlatString(s) {
return s.trim().replace(/\s\s+/g, " ");
}
/**
*
* @param node -
* @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`
* @returns {boolean} -
*/
function isHidden(node, getComputedStyleImplementation) {
if (!(0, _util.isElement)(node)) {
return false;
}
if (node.hasAttribute("hidden") || node.getAttribute("aria-hidden") === "true") {
return true;
}
var style = getComputedStyleImplementation(node);
return style.getPropertyValue("display") === "none" || style.getPropertyValue("visibility") === "hidden";
}
/**
* @param {Node} node -
* @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te
*/
function isControl(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["button", "combobox", "listbox", "textbox"]) || hasAbstractRole(node, "range");
}
function hasAbstractRole(node, role) {
if (!(0, _util.isElement)(node)) {
return false;
}
switch (role) {
case "range":
return (0, _util.hasAnyConcreteRoles)(node, ["meter", "progressbar", "scrollbar", "slider", "spinbutton"]);
default:
throw new TypeError("No knowledge about abstract role '".concat(role, "'. This is likely a bug :("));
}
}
/**
* element.querySelectorAll but also considers owned tree
* @param element
* @param selectors
*/
function querySelectorAllSubtree(element, selectors) {
var elements = (0, _array.default)(element.querySelectorAll(selectors));
(0, _util.queryIdRefs)(element, "aria-owns").forEach(function (root) {
// babel transpiles this assuming an iterator
elements.push.apply(elements, (0, _array.default)(root.querySelectorAll(selectors)));
});
return elements;
}
function querySelectedOptions(listbox) {
if ((0, _util.isHTMLSelectElement)(listbox)) {
// IE11 polyfill
return listbox.selectedOptions || querySelectorAllSubtree(listbox, "[selected]");
}
return querySelectorAllSubtree(listbox, '[aria-selected="true"]');
}
function isMarkedPresentational(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["none", "presentation"]);
}
/**
* Elements specifically listed in html-aam
*
* We don't need this for `label` or `legend` elements.
* Their implicit roles already allow "naming from content".
*
* sources:
*
* - https://w3c.github.io/html-aam/#table-element
*/
function isNativeHostLanguageTextAlternativeElement(node) {
return (0, _util.isHTMLTableCaptionElement)(node);
}
/**
* https://w3c.github.io/aria/#namefromcontent
*/
function allowsNameFromContent(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["button", "cell", "checkbox", "columnheader", "gridcell", "heading", "label", "legend", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "row", "rowheader", "switch", "tab", "tooltip", "treeitem"]);
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/100
*/
function isDescendantOfNativeHostLanguageTextAlternativeElement( // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
node) {
return false;
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/101
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
function computeTooltipAttributeValue(node) {
return null;
}
function getValueOfTextbox(element) {
if ((0, _util.isHTMLInputElement)(element) || (0, _util.isHTMLTextAreaElement)(element)) {
return element.value;
} // https://github.com/eps1lon/dom-accessibility-api/issues/4
return element.textContent || "";
}
function getTextualContent(declaration) {
var content = declaration.getPropertyValue("content");
if (/^["'].*["']$/.test(content)) {
return content.slice(1, -1);
}
return "";
}
/**
* https://html.spec.whatwg.org/multipage/forms.html#category-label
* TODO: form-associated custom elements
* @param element
*/
function isLabelableElement(element) {
var localName = (0, _util.getLocalName)(element);
return localName === "button" || localName === "input" && element.getAttribute("type") !== "hidden" || localName === "meter" || localName === "output" || localName === "progress" || localName === "select" || localName === "textarea";
}
/**
* > [...], then the first such descendant in tree order is the label element's labeled control.
* -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param element
*/
function findLabelableElement(element) {
if (isLabelableElement(element)) {
return element;
}
var labelableElement = null;
element.childNodes.forEach(function (childNode) {
if (labelableElement === null && (0, _util.isElement)(childNode)) {
var descendantLabelableElement = findLabelableElement(childNode);
if (descendantLabelableElement !== null) {
labelableElement = descendantLabelableElement;
}
}
});
return labelableElement;
}
/**
* Polyfill of HTMLLabelElement.control
* https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param label
*/
function getControlOfLabel(label) {
if (label.control !== undefined) {
return label.control;
}
var htmlFor = label.getAttribute("for");
if (htmlFor !== null) {
return label.ownerDocument.getElementById(htmlFor);
}
return findLabelableElement(label);
}
/**
* Polyfill of HTMLInputElement.labels
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels
* @param element
*/
function getLabels(element) {
var labelsProperty = element.labels;
if (labelsProperty === null) {
return labelsProperty;
}
if (labelsProperty !== undefined) {
return (0, _array.default)(labelsProperty);
} // polyfill
if (!isLabelableElement(element)) {
return null;
}
var document = element.ownerDocument;
return (0, _array.default)(document.querySelectorAll("label")).filter(function (label) {
return getControlOfLabel(label) === element;
});
}
/**
* Gets the contents of a slot used for computing the accname
* @param slot
*/
function getSlotContents(slot) {
// Computing the accessible name for elements containing slots is not
// currently defined in the spec. This implementation reflects the
// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.
var assignedNodes = slot.assignedNodes();
if (assignedNodes.length === 0) {
// if no nodes are assigned to the slot, it displays the default content
return (0, _array.default)(slot.childNodes);
}
return assignedNodes;
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te
* @param root
* @param [options]
* @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
function computeTextAlternative(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var consultedNodes = new _SetLike.default();
var window = (0, _util.safeWindow)(root);
var _options$compute = options.compute,
compute = _options$compute === void 0 ? "name" : _options$compute,
_options$computedStyl = options.computedStyleSupportsPseudoElements,
computedStyleSupportsPseudoElements = _options$computedStyl === void 0 ? options.getComputedStyle !== undefined : _options$computedStyl,
_options$getComputedS = options.getComputedStyle,
getComputedStyle = _options$getComputedS === void 0 ? window.getComputedStyle.bind(window) : _options$getComputedS; // 2F.i
function computeMiscTextAlternative(node, context) {
var accumulatedText = "";
if ((0, _util.isElement)(node) && computedStyleSupportsPseudoElements) {
var pseudoBefore = getComputedStyle(node, "::before");
var beforeContent = getTextualContent(pseudoBefore);
accumulatedText = "".concat(beforeContent, " ").concat(accumulatedText);
} // FIXME: Including aria-owns is not defined in the spec
// But it is required in the web-platform-test
var childNodes = (0, _util.isHTMLSlotElement)(node) ? getSlotContents(node) : (0, _array.default)(node.childNodes).concat((0, _util.queryIdRefs)(node, "aria-owns"));
childNodes.forEach(function (child) {
var result = computeTextAlternative(child, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
}); // TODO: Unclear why display affects delimiter
// see https://github.com/w3c/accname/issues/3
var display = (0, _util.isElement)(child) ? getComputedStyle(child).getPropertyValue("display") : "inline";
var separator = display !== "inline" ? " " : ""; // trailing separator for wpt tests
accumulatedText += "".concat(separator).concat(result).concat(separator);
});
if ((0, _util.isElement)(node) && computedStyleSupportsPseudoElements) {
var pseudoAfter = getComputedStyle(node, "::after");
var afterContent = getTextualContent(pseudoAfter);
accumulatedText = "".concat(accumulatedText, " ").concat(afterContent);
}
return accumulatedText;
}
function computeElementTextAlternative(node) {
if (!(0, _util.isElement)(node)) {
return null;
}
/**
*
* @param element
* @param attributeName
* @returns A string non-empty string or `null`
*/
function useAttribute(element, attributeName) {
var attribute = element.getAttributeNode(attributeName);
if (attribute !== null && !consultedNodes.has(attribute) && attribute.value.trim() !== "") {
consultedNodes.add(attribute);
return attribute.value;
}
return null;
} // https://w3c.github.io/html-aam/#fieldset-and-legend-elements
if ((0, _util.isHTMLFieldSetElement)(node)) {
consultedNodes.add(node);
var children = (0, _array.default)(node.childNodes);
for (var i = 0; i < children.length; i += 1) {
var child = children[i];
if ((0, _util.isHTMLLegendElement)(child)) {
return computeTextAlternative(child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if ((0, _util.isHTMLTableElement)(node)) {
// https://w3c.github.io/html-aam/#table-element
consultedNodes.add(node);
var _children = (0, _array.default)(node.childNodes);
for (var _i = 0; _i < _children.length; _i += 1) {
var _child = _children[_i];
if ((0, _util.isHTMLTableCaptionElement)(_child)) {
return computeTextAlternative(_child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if ((0, _util.isSVGSVGElement)(node)) {
// https://www.w3.org/TR/svg-aam-1.0/
consultedNodes.add(node);
var _children2 = (0, _array.default)(node.childNodes);
for (var _i2 = 0; _i2 < _children2.length; _i2 += 1) {
var _child2 = _children2[_i2];
if ((0, _util.isSVGTitleElement)(_child2)) {
return _child2.textContent;
}
}
return null;
} else if ((0, _util.getLocalName)(node) === "img" || (0, _util.getLocalName)(node) === "area") {
// https://w3c.github.io/html-aam/#area-element
// https://w3c.github.io/html-aam/#img-element
var nameFromAlt = useAttribute(node, "alt");
if (nameFromAlt !== null) {
return nameFromAlt;
}
} else if ((0, _util.isHTMLOptGroupElement)(node)) {
var nameFromLabel = useAttribute(node, "label");
if (nameFromLabel !== null) {
return nameFromLabel;
}
}
if ((0, _util.isHTMLInputElement)(node) && (node.type === "button" || node.type === "submit" || node.type === "reset")) {
// https://w3c.github.io/html-aam/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-description-computation
var nameFromValue = useAttribute(node, "value");
if (nameFromValue !== null) {
return nameFromValue;
} // TODO: l10n
if (node.type === "submit") {
return "Submit";
} // TODO: l10n
if (node.type === "reset") {
return "Reset";
}
}
var labels = getLabels(node);
if (labels !== null && labels.length !== 0) {
consultedNodes.add(node);
return (0, _array.default)(labels).map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: true,
isReferenced: false,
recursion: true
});
}).filter(function (label) {
return label.length > 0;
}).join(" ");
} // https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation
// TODO: wpt test consider label elements but html-aam does not mention them
// We follow existing implementations over spec
if ((0, _util.isHTMLInputElement)(node) && node.type === "image") {
var _nameFromAlt = useAttribute(node, "alt");
if (_nameFromAlt !== null) {
return _nameFromAlt;
}
var nameFromTitle = useAttribute(node, "title");
if (nameFromTitle !== null) {
return nameFromTitle;
} // TODO: l10n
return "Submit Query";
}
return useAttribute(node, "title");
}
function computeTextAlternative(current, context) {
if (consultedNodes.has(current)) {
return "";
} // special casing, cheating to make tests pass
// https://github.com/w3c/accname/issues/67
if ((0, _util.hasAnyConcreteRoles)(current, ["menu"])) {
consultedNodes.add(current);
return "";
} // 2A
if (isHidden(current, getComputedStyle) && !context.isReferenced) {
consultedNodes.add(current);
return "";
} // 2B
var labelElements = (0, _util.queryIdRefs)(current, "aria-labelledby");
if (compute === "name" && !context.isReferenced && labelElements.length > 0) {
return labelElements.map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: true,
// thais isn't recursion as specified, otherwise we would skip
// `aria-label` in
// <input id="myself" aria-label="foo" aria-labelledby="myself"
recursion: false
});
}).join(" ");
} // 2C
// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64
// spec says we should only consider skipping if we have a non-empty label
var skipToStep2E = context.recursion && isControl(current) && compute === "name";
if (!skipToStep2E) {
var ariaLabel = ((0, _util.isElement)(current) && current.getAttribute("aria-label") || "").trim();
if (ariaLabel !== "" && compute === "name") {
consultedNodes.add(current);
return ariaLabel;
} // 2D
if (!isMarkedPresentational(current)) {
var elementTextAlternative = computeElementTextAlternative(current);
if (elementTextAlternative !== null) {
consultedNodes.add(current);
return elementTextAlternative;
}
}
} // 2E
if (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {
if ((0, _util.hasAnyConcreteRoles)(current, ["combobox", "listbox"])) {
consultedNodes.add(current);
var selectedOptions = querySelectedOptions(current);
if (selectedOptions.length === 0) {
// defined per test `name_heading_combobox`
return (0, _util.isHTMLInputElement)(current) ? current.value : "";
}
return (0, _array.default)(selectedOptions).map(function (selectedOption) {
return computeTextAlternative(selectedOption, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
});
}).join(" ");
}
if (hasAbstractRole(current, "range")) {
consultedNodes.add(current);
if (current.hasAttribute("aria-valuetext")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuetext");
}
if (current.hasAttribute("aria-valuenow")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuenow");
} // Otherwise, use the value as specified by a host language attribute.
return current.getAttribute("value") || "";
}
if ((0, _util.hasAnyConcreteRoles)(current, ["textbox"])) {
consultedNodes.add(current);
return getValueOfTextbox(current);
}
} // 2F: https://w3c.github.io/accname/#step2F
if (allowsNameFromContent(current) || (0, _util.isElement)(current) && context.isReferenced || isNativeHostLanguageTextAlternativeElement(current) || isDescendantOfNativeHostLanguageTextAlternativeElement(current)) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
if (current.nodeType === current.TEXT_NODE) {
consultedNodes.add(current);
return current.textContent || "";
}
if (context.recursion) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
var tooltipAttributeValue = computeTooltipAttributeValue(current);
if (tooltipAttributeValue !== null) {
consultedNodes.add(current);
return tooltipAttributeValue;
} // TODO should this be reachable?
consultedNodes.add(current);
return "";
}
return asFlatString(computeTextAlternative(root, {
isEmbeddedInLabel: false,
// by spec computeAccessibleDescription starts with the referenced elements as roots
isReferenced: compute === "description",
recursion: false
}));
}
//# sourceMappingURL=accessible-name-and-description.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,592 @@
/**
* implements https://w3c.github.io/accname/
*/
import ArrayFrom from "./polyfills/array.from.mjs";
import SetLike from "./polyfills/SetLike.mjs";
import { hasAnyConcreteRoles, isElement, isHTMLTableCaptionElement, isHTMLInputElement, isHTMLSelectElement, isHTMLTextAreaElement, safeWindow, isHTMLFieldSetElement, isHTMLLegendElement, isHTMLOptGroupElement, isHTMLTableElement, isHTMLSlotElement, isSVGSVGElement, isSVGTitleElement, queryIdRefs, getLocalName } from "./util.mjs";
/**
* A string of characters where all carriage returns, newlines, tabs, and form-feeds are replaced with a single space, and multiple spaces are reduced to a single space. The string contains only character data; it does not contain any markup.
*/
/**
*
* @param {string} string -
* @returns {FlatString} -
*/
function asFlatString(s) {
return s.trim().replace(/\s\s+/g, " ");
}
/**
*
* @param node -
* @param options - These are not optional to prevent accidentally calling it without options in `computeAccessibleName`
* @returns {boolean} -
*/
function isHidden(node, getComputedStyleImplementation) {
if (!isElement(node)) {
return false;
}
if (node.hasAttribute("hidden") || node.getAttribute("aria-hidden") === "true") {
return true;
}
var style = getComputedStyleImplementation(node);
return style.getPropertyValue("display") === "none" || style.getPropertyValue("visibility") === "hidden";
}
/**
* @param {Node} node -
* @returns {boolean} - As defined in step 2E of https://w3c.github.io/accname/#mapping_additional_nd_te
*/
function isControl(node) {
return hasAnyConcreteRoles(node, ["button", "combobox", "listbox", "textbox"]) || hasAbstractRole(node, "range");
}
function hasAbstractRole(node, role) {
if (!isElement(node)) {
return false;
}
switch (role) {
case "range":
return hasAnyConcreteRoles(node, ["meter", "progressbar", "scrollbar", "slider", "spinbutton"]);
default:
throw new TypeError("No knowledge about abstract role '".concat(role, "'. This is likely a bug :("));
}
}
/**
* element.querySelectorAll but also considers owned tree
* @param element
* @param selectors
*/
function querySelectorAllSubtree(element, selectors) {
var elements = ArrayFrom(element.querySelectorAll(selectors));
queryIdRefs(element, "aria-owns").forEach(function (root) {
// babel transpiles this assuming an iterator
elements.push.apply(elements, ArrayFrom(root.querySelectorAll(selectors)));
});
return elements;
}
function querySelectedOptions(listbox) {
if (isHTMLSelectElement(listbox)) {
// IE11 polyfill
return listbox.selectedOptions || querySelectorAllSubtree(listbox, "[selected]");
}
return querySelectorAllSubtree(listbox, '[aria-selected="true"]');
}
function isMarkedPresentational(node) {
return hasAnyConcreteRoles(node, ["none", "presentation"]);
}
/**
* Elements specifically listed in html-aam
*
* We don't need this for `label` or `legend` elements.
* Their implicit roles already allow "naming from content".
*
* sources:
*
* - https://w3c.github.io/html-aam/#table-element
*/
function isNativeHostLanguageTextAlternativeElement(node) {
return isHTMLTableCaptionElement(node);
}
/**
* https://w3c.github.io/aria/#namefromcontent
*/
function allowsNameFromContent(node) {
return hasAnyConcreteRoles(node, ["button", "cell", "checkbox", "columnheader", "gridcell", "heading", "label", "legend", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "row", "rowheader", "switch", "tab", "tooltip", "treeitem"]);
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/100
*/
function isDescendantOfNativeHostLanguageTextAlternativeElement( // eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
node) {
return false;
}
/**
* TODO https://github.com/eps1lon/dom-accessibility-api/issues/101
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not implemented yet
function computeTooltipAttributeValue(node) {
return null;
}
function getValueOfTextbox(element) {
if (isHTMLInputElement(element) || isHTMLTextAreaElement(element)) {
return element.value;
} // https://github.com/eps1lon/dom-accessibility-api/issues/4
return element.textContent || "";
}
function getTextualContent(declaration) {
var content = declaration.getPropertyValue("content");
if (/^["'].*["']$/.test(content)) {
return content.slice(1, -1);
}
return "";
}
/**
* https://html.spec.whatwg.org/multipage/forms.html#category-label
* TODO: form-associated custom elements
* @param element
*/
function isLabelableElement(element) {
var localName = getLocalName(element);
return localName === "button" || localName === "input" && element.getAttribute("type") !== "hidden" || localName === "meter" || localName === "output" || localName === "progress" || localName === "select" || localName === "textarea";
}
/**
* > [...], then the first such descendant in tree order is the label element's labeled control.
* -- https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param element
*/
function findLabelableElement(element) {
if (isLabelableElement(element)) {
return element;
}
var labelableElement = null;
element.childNodes.forEach(function (childNode) {
if (labelableElement === null && isElement(childNode)) {
var descendantLabelableElement = findLabelableElement(childNode);
if (descendantLabelableElement !== null) {
labelableElement = descendantLabelableElement;
}
}
});
return labelableElement;
}
/**
* Polyfill of HTMLLabelElement.control
* https://html.spec.whatwg.org/multipage/forms.html#labeled-control
* @param label
*/
function getControlOfLabel(label) {
if (label.control !== undefined) {
return label.control;
}
var htmlFor = label.getAttribute("for");
if (htmlFor !== null) {
return label.ownerDocument.getElementById(htmlFor);
}
return findLabelableElement(label);
}
/**
* Polyfill of HTMLInputElement.labels
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/labels
* @param element
*/
function getLabels(element) {
var labelsProperty = element.labels;
if (labelsProperty === null) {
return labelsProperty;
}
if (labelsProperty !== undefined) {
return ArrayFrom(labelsProperty);
} // polyfill
if (!isLabelableElement(element)) {
return null;
}
var document = element.ownerDocument;
return ArrayFrom(document.querySelectorAll("label")).filter(function (label) {
return getControlOfLabel(label) === element;
});
}
/**
* Gets the contents of a slot used for computing the accname
* @param slot
*/
function getSlotContents(slot) {
// Computing the accessible name for elements containing slots is not
// currently defined in the spec. This implementation reflects the
// behavior of NVDA 2020.2/Firefox 81 and iOS VoiceOver/Safari 13.6.
var assignedNodes = slot.assignedNodes();
if (assignedNodes.length === 0) {
// if no nodes are assigned to the slot, it displays the default content
return ArrayFrom(slot.childNodes);
}
return assignedNodes;
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_te
* @param root
* @param [options]
* @param [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export function computeTextAlternative(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var consultedNodes = new SetLike();
var window = safeWindow(root);
var _options$compute = options.compute,
compute = _options$compute === void 0 ? "name" : _options$compute,
_options$computedStyl = options.computedStyleSupportsPseudoElements,
computedStyleSupportsPseudoElements = _options$computedStyl === void 0 ? options.getComputedStyle !== undefined : _options$computedStyl,
_options$getComputedS = options.getComputedStyle,
getComputedStyle = _options$getComputedS === void 0 ? window.getComputedStyle.bind(window) : _options$getComputedS; // 2F.i
function computeMiscTextAlternative(node, context) {
var accumulatedText = "";
if (isElement(node) && computedStyleSupportsPseudoElements) {
var pseudoBefore = getComputedStyle(node, "::before");
var beforeContent = getTextualContent(pseudoBefore);
accumulatedText = "".concat(beforeContent, " ").concat(accumulatedText);
} // FIXME: Including aria-owns is not defined in the spec
// But it is required in the web-platform-test
var childNodes = isHTMLSlotElement(node) ? getSlotContents(node) : ArrayFrom(node.childNodes).concat(queryIdRefs(node, "aria-owns"));
childNodes.forEach(function (child) {
var result = computeTextAlternative(child, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
}); // TODO: Unclear why display affects delimiter
// see https://github.com/w3c/accname/issues/3
var display = isElement(child) ? getComputedStyle(child).getPropertyValue("display") : "inline";
var separator = display !== "inline" ? " " : ""; // trailing separator for wpt tests
accumulatedText += "".concat(separator).concat(result).concat(separator);
});
if (isElement(node) && computedStyleSupportsPseudoElements) {
var pseudoAfter = getComputedStyle(node, "::after");
var afterContent = getTextualContent(pseudoAfter);
accumulatedText = "".concat(accumulatedText, " ").concat(afterContent);
}
return accumulatedText;
}
function computeElementTextAlternative(node) {
if (!isElement(node)) {
return null;
}
/**
*
* @param element
* @param attributeName
* @returns A string non-empty string or `null`
*/
function useAttribute(element, attributeName) {
var attribute = element.getAttributeNode(attributeName);
if (attribute !== null && !consultedNodes.has(attribute) && attribute.value.trim() !== "") {
consultedNodes.add(attribute);
return attribute.value;
}
return null;
} // https://w3c.github.io/html-aam/#fieldset-and-legend-elements
if (isHTMLFieldSetElement(node)) {
consultedNodes.add(node);
var children = ArrayFrom(node.childNodes);
for (var i = 0; i < children.length; i += 1) {
var child = children[i];
if (isHTMLLegendElement(child)) {
return computeTextAlternative(child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if (isHTMLTableElement(node)) {
// https://w3c.github.io/html-aam/#table-element
consultedNodes.add(node);
var _children = ArrayFrom(node.childNodes);
for (var _i = 0; _i < _children.length; _i += 1) {
var _child = _children[_i];
if (isHTMLTableCaptionElement(_child)) {
return computeTextAlternative(_child, {
isEmbeddedInLabel: false,
isReferenced: false,
recursion: false
});
}
}
} else if (isSVGSVGElement(node)) {
// https://www.w3.org/TR/svg-aam-1.0/
consultedNodes.add(node);
var _children2 = ArrayFrom(node.childNodes);
for (var _i2 = 0; _i2 < _children2.length; _i2 += 1) {
var _child2 = _children2[_i2];
if (isSVGTitleElement(_child2)) {
return _child2.textContent;
}
}
return null;
} else if (getLocalName(node) === "img" || getLocalName(node) === "area") {
// https://w3c.github.io/html-aam/#area-element
// https://w3c.github.io/html-aam/#img-element
var nameFromAlt = useAttribute(node, "alt");
if (nameFromAlt !== null) {
return nameFromAlt;
}
} else if (isHTMLOptGroupElement(node)) {
var nameFromLabel = useAttribute(node, "label");
if (nameFromLabel !== null) {
return nameFromLabel;
}
}
if (isHTMLInputElement(node) && (node.type === "button" || node.type === "submit" || node.type === "reset")) {
// https://w3c.github.io/html-aam/#input-type-text-input-type-password-input-type-search-input-type-tel-input-type-email-input-type-url-and-textarea-element-accessible-description-computation
var nameFromValue = useAttribute(node, "value");
if (nameFromValue !== null) {
return nameFromValue;
} // TODO: l10n
if (node.type === "submit") {
return "Submit";
} // TODO: l10n
if (node.type === "reset") {
return "Reset";
}
}
var labels = getLabels(node);
if (labels !== null && labels.length !== 0) {
consultedNodes.add(node);
return ArrayFrom(labels).map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: true,
isReferenced: false,
recursion: true
});
}).filter(function (label) {
return label.length > 0;
}).join(" ");
} // https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation
// TODO: wpt test consider label elements but html-aam does not mention them
// We follow existing implementations over spec
if (isHTMLInputElement(node) && node.type === "image") {
var _nameFromAlt = useAttribute(node, "alt");
if (_nameFromAlt !== null) {
return _nameFromAlt;
}
var nameFromTitle = useAttribute(node, "title");
if (nameFromTitle !== null) {
return nameFromTitle;
} // TODO: l10n
return "Submit Query";
}
return useAttribute(node, "title");
}
function computeTextAlternative(current, context) {
if (consultedNodes.has(current)) {
return "";
} // special casing, cheating to make tests pass
// https://github.com/w3c/accname/issues/67
if (hasAnyConcreteRoles(current, ["menu"])) {
consultedNodes.add(current);
return "";
} // 2A
if (isHidden(current, getComputedStyle) && !context.isReferenced) {
consultedNodes.add(current);
return "";
} // 2B
var labelElements = queryIdRefs(current, "aria-labelledby");
if (compute === "name" && !context.isReferenced && labelElements.length > 0) {
return labelElements.map(function (element) {
return computeTextAlternative(element, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: true,
// thais isn't recursion as specified, otherwise we would skip
// `aria-label` in
// <input id="myself" aria-label="foo" aria-labelledby="myself"
recursion: false
});
}).join(" ");
} // 2C
// Changed from the spec in anticipation of https://github.com/w3c/accname/issues/64
// spec says we should only consider skipping if we have a non-empty label
var skipToStep2E = context.recursion && isControl(current) && compute === "name";
if (!skipToStep2E) {
var ariaLabel = (isElement(current) && current.getAttribute("aria-label") || "").trim();
if (ariaLabel !== "" && compute === "name") {
consultedNodes.add(current);
return ariaLabel;
} // 2D
if (!isMarkedPresentational(current)) {
var elementTextAlternative = computeElementTextAlternative(current);
if (elementTextAlternative !== null) {
consultedNodes.add(current);
return elementTextAlternative;
}
}
} // 2E
if (skipToStep2E || context.isEmbeddedInLabel || context.isReferenced) {
if (hasAnyConcreteRoles(current, ["combobox", "listbox"])) {
consultedNodes.add(current);
var selectedOptions = querySelectedOptions(current);
if (selectedOptions.length === 0) {
// defined per test `name_heading_combobox`
return isHTMLInputElement(current) ? current.value : "";
}
return ArrayFrom(selectedOptions).map(function (selectedOption) {
return computeTextAlternative(selectedOption, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
recursion: true
});
}).join(" ");
}
if (hasAbstractRole(current, "range")) {
consultedNodes.add(current);
if (current.hasAttribute("aria-valuetext")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuetext");
}
if (current.hasAttribute("aria-valuenow")) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute guard
return current.getAttribute("aria-valuenow");
} // Otherwise, use the value as specified by a host language attribute.
return current.getAttribute("value") || "";
}
if (hasAnyConcreteRoles(current, ["textbox"])) {
consultedNodes.add(current);
return getValueOfTextbox(current);
}
} // 2F: https://w3c.github.io/accname/#step2F
if (allowsNameFromContent(current) || isElement(current) && context.isReferenced || isNativeHostLanguageTextAlternativeElement(current) || isDescendantOfNativeHostLanguageTextAlternativeElement(current)) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
if (current.nodeType === current.TEXT_NODE) {
consultedNodes.add(current);
return current.textContent || "";
}
if (context.recursion) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false
});
}
var tooltipAttributeValue = computeTooltipAttributeValue(current);
if (tooltipAttributeValue !== null) {
consultedNodes.add(current);
return tooltipAttributeValue;
} // TODO should this be reachable?
consultedNodes.add(current);
return "";
}
return asFlatString(computeTextAlternative(root, {
isEmbeddedInLabel: false,
// by spec computeAccessibleDescription starts with the referenced elements as roots
isReferenced: compute === "description",
recursion: false
}));
}
//# sourceMappingURL=accessible-name-and-description.mjs.map
File diff suppressed because one or more lines are too long
+9
View File
@@ -0,0 +1,9 @@
import { ComputeTextAlternativeOptions } from "./accessible-name-and-description";
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_name
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export declare function computeAccessibleName(root: Element, options?: ComputeTextAlternativeOptions): string;
//# sourceMappingURL=accessible-name.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"accessible-name.d.ts","sourceRoot":"","sources":["../sources/accessible-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,6BAA6B,EAC7B,MAAM,mCAAmC,CAAC;AAsB3C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,6BAAkC,GACzC,MAAM,CAMR"}
+33
View File
@@ -0,0 +1,33 @@
"use strict";
exports.__esModule = true;
exports.computeAccessibleName = computeAccessibleName;
var _accessibleNameAndDescription = require("./accessible-name-and-description");
var _util = require("./util");
/**
* https://w3c.github.io/aria/#namefromprohibited
*/
function prohibitsNaming(node) {
return (0, _util.hasAnyConcreteRoles)(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "paragraph", "presentation", "strong", "subscript", "superscript"]);
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_name
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
function computeAccessibleName(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (prohibitsNaming(root)) {
return "";
}
return (0, _accessibleNameAndDescription.computeTextAlternative)(root, options);
}
//# sourceMappingURL=accessible-name.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-name.ts"],"names":["prohibitsNaming","node","computeAccessibleName","root","options"],"mappings":";;;;;AAAA;;AAIA;;AAEA;AACA;AACA;AACA,SAASA,eAAT,CAAyBC,IAAzB,EAA8C;AAC7C,SAAO,+BAAoBA,IAApB,EAA0B,CAChC,SADgC,EAEhC,MAFgC,EAGhC,UAHgC,EAIhC,UAJgC,EAKhC,SALgC,EAMhC,WANgC,EAOhC,WAPgC,EAQhC,cARgC,EAShC,QATgC,EAUhC,WAVgC,EAWhC,aAXgC,CAA1B,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;;AACT,MAAIJ,eAAe,CAACG,IAAD,CAAnB,EAA2B;AAC1B,WAAO,EAAP;AACA;;AAED,SAAO,0DAAuBA,IAAvB,EAA6BC,OAA7B,CAAP;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { hasAnyConcreteRoles } from \"./util\";\n\n/**\n * https://w3c.github.io/aria/#namefromprohibited\n */\nfunction prohibitsNaming(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"caption\",\n\t\t\"code\",\n\t\t\"deletion\",\n\t\t\"emphasis\",\n\t\t\"generic\",\n\t\t\"insertion\",\n\t\t\"paragraph\",\n\t\t\"presentation\",\n\t\t\"strong\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t]);\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_name\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleName(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tif (prohibitsNaming(root)) {\n\t\treturn \"\";\n\t}\n\n\treturn computeTextAlternative(root, options);\n}\n"],"file":"accessible-name.js"}
+27
View File
@@ -0,0 +1,27 @@
import { computeTextAlternative } from "./accessible-name-and-description.mjs";
import { hasAnyConcreteRoles } from "./util.mjs";
/**
* https://w3c.github.io/aria/#namefromprohibited
*/
function prohibitsNaming(node) {
return hasAnyConcreteRoles(node, ["caption", "code", "deletion", "emphasis", "generic", "insertion", "paragraph", "presentation", "strong", "subscript", "superscript"]);
}
/**
* implements https://w3c.github.io/accname/#mapping_additional_nd_name
* @param root
* @param [options]
* @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`
*/
export function computeAccessibleName(root) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (prohibitsNaming(root)) {
return "";
}
return computeTextAlternative(root, options);
}
//# sourceMappingURL=accessible-name.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../sources/accessible-name.ts"],"names":["computeTextAlternative","hasAnyConcreteRoles","prohibitsNaming","node","computeAccessibleName","root","options"],"mappings":"AAAA,SACCA,sBADD,QAGO,uCAHP;AAIA,SAASC,mBAAT,QAAoC,YAApC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,CAAyBC,IAAzB,EAA8C;AAC7C,SAAOF,mBAAmB,CAACE,IAAD,EAAO,CAChC,SADgC,EAEhC,MAFgC,EAGhC,UAHgC,EAIhC,UAJgC,EAKhC,SALgC,EAMhC,WANgC,EAOhC,WAPgC,EAQhC,cARgC,EAShC,QATgC,EAUhC,WAVgC,EAWhC,aAXgC,CAAP,CAA1B;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,qBAAT,CACNC,IADM,EAGG;AAAA,MADTC,OACS,uEADgC,EAChC;;AACT,MAAIJ,eAAe,CAACG,IAAD,CAAnB,EAA2B;AAC1B,WAAO,EAAP;AACA;;AAED,SAAOL,sBAAsB,CAACK,IAAD,EAAOC,OAAP,CAA7B;AACA","sourcesContent":["import {\n\tcomputeTextAlternative,\n\tComputeTextAlternativeOptions,\n} from \"./accessible-name-and-description\";\nimport { hasAnyConcreteRoles } from \"./util\";\n\n/**\n * https://w3c.github.io/aria/#namefromprohibited\n */\nfunction prohibitsNaming(node: Node): boolean {\n\treturn hasAnyConcreteRoles(node, [\n\t\t\"caption\",\n\t\t\"code\",\n\t\t\"deletion\",\n\t\t\"emphasis\",\n\t\t\"generic\",\n\t\t\"insertion\",\n\t\t\"paragraph\",\n\t\t\"presentation\",\n\t\t\"strong\",\n\t\t\"subscript\",\n\t\t\"superscript\",\n\t]);\n}\n\n/**\n * implements https://w3c.github.io/accname/#mapping_additional_nd_name\n * @param root\n * @param [options]\n * @parma [options.getComputedStyle] - mock window.getComputedStyle. Needs `content`, `display` and `visibility`\n */\nexport function computeAccessibleName(\n\troot: Element,\n\toptions: ComputeTextAlternativeOptions = {}\n): string {\n\tif (prohibitsNaming(root)) {\n\t\treturn \"\";\n\t}\n\n\treturn computeTextAlternative(root, options);\n}\n"],"file":"accessible-name.mjs"}
+2
View File
@@ -0,0 +1,2 @@
export default function getRole(element: Element): string | null;
//# sourceMappingURL=getRole.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getRole.d.ts","sourceRoot":"","sources":["../sources/getRole.ts"],"names":[],"mappings":"AAkHA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAa/D"}
+200
View File
@@ -0,0 +1,200 @@
"use strict";
exports.__esModule = true;
exports.default = getRole;
var _util = require("./util");
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html
var localNameToRoleMappings = {
article: "article",
aside: "complementary",
button: "button",
datalist: "listbox",
dd: "definition",
details: "group",
dialog: "dialog",
dt: "term",
fieldset: "group",
figure: "figure",
// WARNING: Only with an accessible name
form: "form",
footer: "contentinfo",
h1: "heading",
h2: "heading",
h3: "heading",
h4: "heading",
h5: "heading",
h6: "heading",
header: "banner",
hr: "separator",
html: "document",
legend: "legend",
li: "listitem",
math: "math",
main: "main",
menu: "list",
nav: "navigation",
ol: "list",
optgroup: "group",
// WARNING: Only in certain context
option: "option",
output: "status",
progress: "progressbar",
// WARNING: Only with an accessible name
section: "region",
summary: "button",
table: "table",
tbody: "rowgroup",
textarea: "textbox",
tfoot: "rowgroup",
// WARNING: Only in certain context
td: "cell",
th: "columnheader",
thead: "rowgroup",
tr: "row",
ul: "list"
};
var prohibitedAttributes = {
caption: new Set(["aria-label", "aria-labelledby"]),
code: new Set(["aria-label", "aria-labelledby"]),
deletion: new Set(["aria-label", "aria-labelledby"]),
emphasis: new Set(["aria-label", "aria-labelledby"]),
generic: new Set(["aria-label", "aria-labelledby", "aria-roledescription"]),
insertion: new Set(["aria-label", "aria-labelledby"]),
paragraph: new Set(["aria-label", "aria-labelledby"]),
presentation: new Set(["aria-label", "aria-labelledby"]),
strong: new Set(["aria-label", "aria-labelledby"]),
subscript: new Set(["aria-label", "aria-labelledby"]),
superscript: new Set(["aria-label", "aria-labelledby"])
};
/**
*
* @param element
* @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.
*/
function hasGlobalAriaAttributes(element, role) {
// https://rawgit.com/w3c/aria/stable/#global_states
// commented attributes are deprecated
return ["aria-atomic", "aria-busy", "aria-controls", "aria-current", "aria-describedby", "aria-details", // "disabled",
"aria-dropeffect", // "errormessage",
"aria-flowto", "aria-grabbed", // "haspopup",
"aria-hidden", // "invalid",
"aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-live", "aria-owns", "aria-relevant", "aria-roledescription"].some(function (attributeName) {
var _prohibitedAttributes;
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName));
});
}
function ignorePresentationalRole(element, implicitRole) {
// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none
return hasGlobalAriaAttributes(element, implicitRole);
}
function getRole(element) {
var explicitRole = getExplicitRole(element);
if (explicitRole === null || explicitRole === "presentation") {
var implicitRole = getImplicitRole(element);
if (explicitRole !== "presentation" || ignorePresentationalRole(element, implicitRole || "")) {
return implicitRole;
}
}
return explicitRole;
}
function getImplicitRole(element) {
var mappedByTag = localNameToRoleMappings[(0, _util.getLocalName)(element)];
if (mappedByTag !== undefined) {
return mappedByTag;
}
switch ((0, _util.getLocalName)(element)) {
case "a":
case "area":
case "link":
if (element.hasAttribute("href")) {
return "link";
}
break;
case "img":
if (element.getAttribute("alt") === "" && !ignorePresentationalRole(element, "img")) {
return "presentation";
}
return "img";
case "input":
{
var _ref = element,
type = _ref.type;
switch (type) {
case "button":
case "image":
case "reset":
case "submit":
return "button";
case "checkbox":
case "radio":
return type;
case "range":
return "slider";
case "email":
case "tel":
case "text":
case "url":
if (element.hasAttribute("list")) {
return "combobox";
}
return "textbox";
case "search":
if (element.hasAttribute("list")) {
return "combobox";
}
return "searchbox";
default:
return null;
}
}
case "select":
if (element.hasAttribute("multiple") || element.size > 1) {
return "listbox";
}
return "combobox";
}
return null;
}
function getExplicitRole(element) {
var role = element.getAttribute("role");
if (role !== null) {
var explicitRole = role.trim().split(" ")[0]; // String.prototype.split(sep, limit) will always return an array with at least one member
// as long as limit is either undefined or > 0
if (explicitRole.length > 0) {
return explicitRole;
}
}
return null;
}
//# sourceMappingURL=getRole.js.map
File diff suppressed because one or more lines are too long
+194
View File
@@ -0,0 +1,194 @@
// https://w3c.github.io/html-aria/#document-conformance-requirements-for-use-of-aria-attributes-in-html
import { getLocalName } from "./util.mjs";
var localNameToRoleMappings = {
article: "article",
aside: "complementary",
button: "button",
datalist: "listbox",
dd: "definition",
details: "group",
dialog: "dialog",
dt: "term",
fieldset: "group",
figure: "figure",
// WARNING: Only with an accessible name
form: "form",
footer: "contentinfo",
h1: "heading",
h2: "heading",
h3: "heading",
h4: "heading",
h5: "heading",
h6: "heading",
header: "banner",
hr: "separator",
html: "document",
legend: "legend",
li: "listitem",
math: "math",
main: "main",
menu: "list",
nav: "navigation",
ol: "list",
optgroup: "group",
// WARNING: Only in certain context
option: "option",
output: "status",
progress: "progressbar",
// WARNING: Only with an accessible name
section: "region",
summary: "button",
table: "table",
tbody: "rowgroup",
textarea: "textbox",
tfoot: "rowgroup",
// WARNING: Only in certain context
td: "cell",
th: "columnheader",
thead: "rowgroup",
tr: "row",
ul: "list"
};
var prohibitedAttributes = {
caption: new Set(["aria-label", "aria-labelledby"]),
code: new Set(["aria-label", "aria-labelledby"]),
deletion: new Set(["aria-label", "aria-labelledby"]),
emphasis: new Set(["aria-label", "aria-labelledby"]),
generic: new Set(["aria-label", "aria-labelledby", "aria-roledescription"]),
insertion: new Set(["aria-label", "aria-labelledby"]),
paragraph: new Set(["aria-label", "aria-labelledby"]),
presentation: new Set(["aria-label", "aria-labelledby"]),
strong: new Set(["aria-label", "aria-labelledby"]),
subscript: new Set(["aria-label", "aria-labelledby"]),
superscript: new Set(["aria-label", "aria-labelledby"])
};
/**
*
* @param element
* @param role The role used for this element. This is specified to control whether you want to use the implicit or explicit role.
*/
function hasGlobalAriaAttributes(element, role) {
// https://rawgit.com/w3c/aria/stable/#global_states
// commented attributes are deprecated
return ["aria-atomic", "aria-busy", "aria-controls", "aria-current", "aria-describedby", "aria-details", // "disabled",
"aria-dropeffect", // "errormessage",
"aria-flowto", "aria-grabbed", // "haspopup",
"aria-hidden", // "invalid",
"aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-live", "aria-owns", "aria-relevant", "aria-roledescription"].some(function (attributeName) {
var _prohibitedAttributes;
return element.hasAttribute(attributeName) && !((_prohibitedAttributes = prohibitedAttributes[role]) !== null && _prohibitedAttributes !== void 0 && _prohibitedAttributes.has(attributeName));
});
}
function ignorePresentationalRole(element, implicitRole) {
// https://rawgit.com/w3c/aria/stable/#conflict_resolution_presentation_none
return hasGlobalAriaAttributes(element, implicitRole);
}
export default function getRole(element) {
var explicitRole = getExplicitRole(element);
if (explicitRole === null || explicitRole === "presentation") {
var implicitRole = getImplicitRole(element);
if (explicitRole !== "presentation" || ignorePresentationalRole(element, implicitRole || "")) {
return implicitRole;
}
}
return explicitRole;
}
function getImplicitRole(element) {
var mappedByTag = localNameToRoleMappings[getLocalName(element)];
if (mappedByTag !== undefined) {
return mappedByTag;
}
switch (getLocalName(element)) {
case "a":
case "area":
case "link":
if (element.hasAttribute("href")) {
return "link";
}
break;
case "img":
if (element.getAttribute("alt") === "" && !ignorePresentationalRole(element, "img")) {
return "presentation";
}
return "img";
case "input":
{
var _ref = element,
type = _ref.type;
switch (type) {
case "button":
case "image":
case "reset":
case "submit":
return "button";
case "checkbox":
case "radio":
return type;
case "range":
return "slider";
case "email":
case "tel":
case "text":
case "url":
if (element.hasAttribute("list")) {
return "combobox";
}
return "textbox";
case "search":
if (element.hasAttribute("list")) {
return "combobox";
}
return "searchbox";
default:
return null;
}
}
case "select":
if (element.hasAttribute("multiple") || element.size > 1) {
return "listbox";
}
return "combobox";
}
return null;
}
function getExplicitRole(element) {
var role = element.getAttribute("role");
if (role !== null) {
var explicitRole = role.trim().split(" ")[0]; // String.prototype.split(sep, limit) will always return an array with at least one member
// as long as limit is either undefined or > 0
if (explicitRole.length > 0) {
return explicitRole;
}
}
return null;
}
//# sourceMappingURL=getRole.mjs.map
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
export { computeAccessibleDescription } from "./accessible-description";
export { computeAccessibleName } from "./accessible-name";
export { default as getRole } from "./getRole";
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../sources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
exports.__esModule = true;
exports.getRole = exports.computeAccessibleName = exports.computeAccessibleDescription = void 0;
var _accessibleDescription = require("./accessible-description");
exports.computeAccessibleDescription = _accessibleDescription.computeAccessibleDescription;
var _accessibleName = require("./accessible-name");
exports.computeAccessibleName = _accessibleName.computeAccessibleName;
var _getRole = _interopRequireDefault(require("./getRole"));
exports.getRole = _getRole.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../sources/index.ts"],"names":[],"mappings":";;;;;AAAA;;;;AACA;;;;AACA","sourcesContent":["export { computeAccessibleDescription } from \"./accessible-description\";\nexport { computeAccessibleName } from \"./accessible-name\";\nexport { default as getRole } from \"./getRole\";\n"],"file":"index.js"}
+4
View File
@@ -0,0 +1,4 @@
export { computeAccessibleDescription } from "./accessible-description.mjs";
export { computeAccessibleName } from "./accessible-name.mjs";
export { default as getRole } from "./getRole.mjs";
//# sourceMappingURL=index.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../sources/index.ts"],"names":["computeAccessibleDescription","computeAccessibleName","default","getRole"],"mappings":"AAAA,SAASA,4BAAT,QAA6C,8BAA7C;AACA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAASC,OAAO,IAAIC,OAApB,QAAmC,eAAnC","sourcesContent":["export { computeAccessibleDescription } from \"./accessible-description\";\nexport { computeAccessibleName } from \"./accessible-name\";\nexport { default as getRole } from \"./getRole\";\n"],"file":"index.mjs"}
+14
View File
@@ -0,0 +1,14 @@
declare global {
class Set<T> {
constructor(items?: T[]);
add(value: T): this;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: unknown): void;
has(value: T): boolean;
readonly size: number;
}
}
declare const _default: typeof Set;
export default _default;
//# sourceMappingURL=SetLike.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"SetLike.d.ts","sourceRoot":"","sources":["../../sources/polyfills/SetLike.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACd,MAAM,GAAG,CAAC,CAAC;oBAEE,KAAK,CAAC,EAAE,CAAC,EAAE;QACvB,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;QACnB,KAAK,IAAI,IAAI;QACb,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;QACzB,OAAO,CACN,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EACtD,OAAO,CAAC,EAAE,OAAO,GACf,IAAI;QACP,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KAItB;CACD;;AAuCD,wBAA0D"}
+76
View File
@@ -0,0 +1,76 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// for environments without Set we fallback to arrays with unique members
var SetLike = /*#__PURE__*/function () {
function SetLike() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, SetLike);
_defineProperty(this, "items", void 0);
this.items = items;
}
_createClass(SetLike, [{
key: "add",
value: function add(value) {
if (this.has(value) === false) {
this.items.push(value);
}
return this;
}
}, {
key: "clear",
value: function clear() {
this.items = [];
}
}, {
key: "delete",
value: function _delete(value) {
var previousLength = this.items.length;
this.items = this.items.filter(function (item) {
return item !== value;
});
return previousLength !== this.items.length;
}
}, {
key: "forEach",
value: function forEach(callbackfn) {
var _this = this;
this.items.forEach(function (item) {
callbackfn(item, item, _this);
});
}
}, {
key: "has",
value: function has(value) {
return this.items.indexOf(value) !== -1;
}
}, {
key: "size",
get: function get() {
return this.items.length;
}
}]);
return SetLike;
}();
var _default = typeof Set === "undefined" ? Set : SetLike;
exports.default = _default;
//# sourceMappingURL=SetLike.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../sources/polyfills/SetLike.ts"],"names":["SetLike","items","value","has","push","previousLength","length","filter","item","callbackfn","forEach","indexOf","Set"],"mappings":";;;;;;;;;;;;;AAmBA;IACMA,O;AAGL,qBAA6B;AAAA,QAAjBC,KAAiB,uEAAJ,EAAI;;AAAA;;AAAA;;AAC5B,SAAKA,KAAL,GAAaA,KAAb;AACA;;;;WAED,aAAIC,KAAJ,EAAoB;AACnB,UAAI,KAAKC,GAAL,CAASD,KAAT,MAAoB,KAAxB,EAA+B;AAC9B,aAAKD,KAAL,CAAWG,IAAX,CAAgBF,KAAhB;AACA;;AACD,aAAO,IAAP;AACA;;;WACD,iBAAc;AACb,WAAKD,KAAL,GAAa,EAAb;AACA;;;WACD,iBAAOC,KAAP,EAA0B;AACzB,UAAMG,cAAc,GAAG,KAAKJ,KAAL,CAAWK,MAAlC;AACA,WAAKL,KAAL,GAAa,KAAKA,KAAL,CAAWM,MAAX,CAAkB,UAACC,IAAD;AAAA,eAAUA,IAAI,KAAKN,KAAnB;AAAA,OAAlB,CAAb;AAEA,aAAOG,cAAc,KAAK,KAAKJ,KAAL,CAAWK,MAArC;AACA;;;WACD,iBAAQG,UAAR,EAAsE;AAAA;;AACrE,WAAKR,KAAL,CAAWS,OAAX,CAAmB,UAACF,IAAD,EAAU;AAC5BC,QAAAA,UAAU,CAACD,IAAD,EAAOA,IAAP,EAAa,KAAb,CAAV;AACA,OAFD;AAGA;;;WACD,aAAIN,KAAJ,EAAuB;AACtB,aAAO,KAAKD,KAAL,CAAWU,OAAX,CAAmBT,KAAnB,MAA8B,CAAC,CAAtC;AACA;;;SAED,eAAmB;AAClB,aAAO,KAAKD,KAAL,CAAWK,MAAlB;AACA;;;;;;eAGa,OAAOM,GAAP,KAAe,WAAf,GAA6BA,GAA7B,GAAmCZ,O","sourcesContent":["declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n"],"file":"SetLike.js"}
+69
View File
@@ -0,0 +1,69 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// for environments without Set we fallback to arrays with unique members
var SetLike = /*#__PURE__*/function () {
function SetLike() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, SetLike);
_defineProperty(this, "items", void 0);
this.items = items;
}
_createClass(SetLike, [{
key: "add",
value: function add(value) {
if (this.has(value) === false) {
this.items.push(value);
}
return this;
}
}, {
key: "clear",
value: function clear() {
this.items = [];
}
}, {
key: "delete",
value: function _delete(value) {
var previousLength = this.items.length;
this.items = this.items.filter(function (item) {
return item !== value;
});
return previousLength !== this.items.length;
}
}, {
key: "forEach",
value: function forEach(callbackfn) {
var _this = this;
this.items.forEach(function (item) {
callbackfn(item, item, _this);
});
}
}, {
key: "has",
value: function has(value) {
return this.items.indexOf(value) !== -1;
}
}, {
key: "size",
get: function get() {
return this.items.length;
}
}]);
return SetLike;
}();
export default typeof Set === "undefined" ? Set : SetLike;
//# sourceMappingURL=SetLike.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../sources/polyfills/SetLike.ts"],"names":["SetLike","items","value","has","push","previousLength","length","filter","item","callbackfn","forEach","indexOf","Set"],"mappings":";;;;;;;;AAmBA;IACMA,O;AAGL,qBAA6B;AAAA,QAAjBC,KAAiB,uEAAJ,EAAI;;AAAA;;AAAA;;AAC5B,SAAKA,KAAL,GAAaA,KAAb;AACA;;;;WAED,aAAIC,KAAJ,EAAoB;AACnB,UAAI,KAAKC,GAAL,CAASD,KAAT,MAAoB,KAAxB,EAA+B;AAC9B,aAAKD,KAAL,CAAWG,IAAX,CAAgBF,KAAhB;AACA;;AACD,aAAO,IAAP;AACA;;;WACD,iBAAc;AACb,WAAKD,KAAL,GAAa,EAAb;AACA;;;WACD,iBAAOC,KAAP,EAA0B;AACzB,UAAMG,cAAc,GAAG,KAAKJ,KAAL,CAAWK,MAAlC;AACA,WAAKL,KAAL,GAAa,KAAKA,KAAL,CAAWM,MAAX,CAAkB,UAACC,IAAD;AAAA,eAAUA,IAAI,KAAKN,KAAnB;AAAA,OAAlB,CAAb;AAEA,aAAOG,cAAc,KAAK,KAAKJ,KAAL,CAAWK,MAArC;AACA;;;WACD,iBAAQG,UAAR,EAAsE;AAAA;;AACrE,WAAKR,KAAL,CAAWS,OAAX,CAAmB,UAACF,IAAD,EAAU;AAC5BC,QAAAA,UAAU,CAACD,IAAD,EAAOA,IAAP,EAAa,KAAb,CAAV;AACA,OAFD;AAGA;;;WACD,aAAIN,KAAJ,EAAuB;AACtB,aAAO,KAAKD,KAAL,CAAWU,OAAX,CAAmBT,KAAnB,MAA8B,CAAC,CAAtC;AACA;;;SAED,eAAmB;AAClB,aAAO,KAAKD,KAAL,CAAWK,MAAlB;AACA;;;;;;AAGF,eAAe,OAAOM,GAAP,KAAe,WAAf,GAA6BA,GAA7B,GAAmCZ,OAAlD","sourcesContent":["declare global {\n\tclass Set<T> {\n\t\t// es2015.collection.d.ts\n\t\tconstructor(items?: T[]);\n\t\tadd(value: T): this;\n\t\tclear(): void;\n\t\tdelete(value: T): boolean;\n\t\tforEach(\n\t\t\tcallbackfn: (value: T, value2: T, set: Set<T>) => void,\n\t\t\tthisArg?: unknown\n\t\t): void;\n\t\thas(value: T): boolean;\n\t\treadonly size: number;\n\n\t\t// es2015.iterable.d.ts\n\t\t// no implemennted\n\t}\n}\n\n// for environments without Set we fallback to arrays with unique members\nclass SetLike<T> implements Set<T> {\n\tprivate items: T[];\n\n\tconstructor(items: T[] = []) {\n\t\tthis.items = items;\n\t}\n\n\tadd(value: T): this {\n\t\tif (this.has(value) === false) {\n\t\t\tthis.items.push(value);\n\t\t}\n\t\treturn this;\n\t}\n\tclear(): void {\n\t\tthis.items = [];\n\t}\n\tdelete(value: T): boolean {\n\t\tconst previousLength = this.items.length;\n\t\tthis.items = this.items.filter((item) => item !== value);\n\n\t\treturn previousLength !== this.items.length;\n\t}\n\tforEach(callbackfn: (value: T, value2: T, set: Set<T>) => void): void {\n\t\tthis.items.forEach((item) => {\n\t\t\tcallbackfn(item, item, this);\n\t\t});\n\t}\n\thas(value: T): boolean {\n\t\treturn this.items.indexOf(value) !== -1;\n\t}\n\n\tget size(): number {\n\t\treturn this.items.length;\n\t}\n}\n\nexport default typeof Set === \"undefined\" ? Set : SetLike;\n"],"file":"SetLike.mjs"}
+6
View File
@@ -0,0 +1,6 @@
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
export default function arrayFrom<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
//# sourceMappingURL=array.from.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"array.from.d.ts","sourceRoot":"","sources":["../../sources/polyfills/array.from.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC"}
+99
View File
@@ -0,0 +1,99 @@
"use strict";
exports.__esModule = true;
exports.default = arrayFrom;
/**
* @source {https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill}
* but without thisArg (too hard to type, no need to `this`)
*/
var toStr = Object.prototype.toString;
function isCallable(fn) {
return typeof fn === "function" || toStr.call(fn) === "[object Function]";
}
function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
}
var maxSafeInteger = Math.pow(2, 53) - 1;
function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
}
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
function arrayFrom(arrayLike, mapFn) {
// 1. Let C be the this value.
// edit(@eps1lon): we're not calling it as Array.from
var C = Array; // 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike); // 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
} // 4. If mapfn is undefined, then let mapping be false.
// const mapFn = arguments.length > 1 ? arguments[1] : void undefined;
if (typeof mapFn !== "undefined") {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError("Array.from: when provided, the second argument must be a function");
}
} // 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length); // 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method
// of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0.
var k = 0; // 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = mapFn(kValue, k);
} else {
A[k] = kValue;
}
k += 1;
} // 18. Let putStatus be Put(A, "length", len, true).
A.length = len; // 20. Return A.
return A;
}
//# sourceMappingURL=array.from.js.map
File diff suppressed because one or more lines are too long
+94
View File
@@ -0,0 +1,94 @@
/**
* @source {https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill}
* but without thisArg (too hard to type, no need to `this`)
*/
var toStr = Object.prototype.toString;
function isCallable(fn) {
return typeof fn === "function" || toStr.call(fn) === "[object Function]";
}
function toInteger(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number === 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
}
var maxSafeInteger = Math.pow(2, 53) - 1;
function toLength(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
}
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
/**
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
export default function arrayFrom(arrayLike, mapFn) {
// 1. Let C be the this value.
// edit(@eps1lon): we're not calling it as Array.from
var C = Array; // 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike); // 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
} // 4. If mapfn is undefined, then let mapping be false.
// const mapFn = arguments.length > 1 ? arguments[1] : void undefined;
if (typeof mapFn !== "undefined") {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError("Array.from: when provided, the second argument must be a function");
}
} // 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length); // 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method
// of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len); // 16. Let k be 0.
var k = 0; // 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = mapFn(kValue, k);
} else {
A[k] = kValue;
}
k += 1;
} // 18. Let putStatus be Put(A, "length", len, true).
A.length = len; // 20. Return A.
return A;
}
//# sourceMappingURL=array.from.mjs.map
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=iterator.d.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"iterator.d.js"}
+2
View File
@@ -0,0 +1,2 @@
//# sourceMappingURL=iterator.d.mjs.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"iterator.d.mjs"}
+28
View File
@@ -0,0 +1,28 @@
/**
* Safe Element.localName for all supported environments
* @param element
*/
export declare function getLocalName(element: Element): string;
export declare function isElement(node: Node | null): node is Element;
export declare function isHTMLTableCaptionElement(node: Node | null): node is HTMLTableCaptionElement;
export declare function isHTMLInputElement(node: Node | null): node is HTMLInputElement;
export declare function isHTMLOptGroupElement(node: Node | null): node is HTMLOptGroupElement;
export declare function isHTMLSelectElement(node: Node | null): node is HTMLSelectElement;
export declare function isHTMLTableElement(node: Node | null): node is HTMLTableElement;
export declare function isHTMLTextAreaElement(node: Node | null): node is HTMLTextAreaElement;
export declare function safeWindow(node: Node): Window;
export declare function isHTMLFieldSetElement(node: Node | null): node is HTMLFieldSetElement;
export declare function isHTMLLegendElement(node: Node | null): node is HTMLLegendElement;
export declare function isHTMLSlotElement(node: Node | null): node is HTMLSlotElement;
export declare function isSVGElement(node: Node | null): node is SVGElement;
export declare function isSVGSVGElement(node: Node | null): node is SVGSVGElement;
export declare function isSVGTitleElement(node: Node | null): node is SVGTitleElement;
/**
*
* @param {Node} node -
* @param {string} attributeName -
* @returns {Element[]} -
*/
export declare function queryIdRefs(node: Node, attributeName: string): Element[];
export declare function hasAnyConcreteRoles(node: Node, roles: Array<string | null>): node is Element;
//# sourceMappingURL=util.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../sources/util.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAOrD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,CAE5D;AAED,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,uBAAuB,CAEjC;AAED,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,gBAAgB,CAE1B;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,mBAAmB,CAE7B;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,iBAAiB,CAE3B;AAED,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,gBAAgB,CAE1B;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,mBAAmB,CAE7B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQ7C;AAED,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,mBAAmB,CAE7B;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,GAAG,IAAI,GACf,IAAI,IAAI,iBAAiB,CAE3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,UAAU,CAElE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,aAAa,CAExE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,EAAE,CAcxE;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GACzB,IAAI,IAAI,OAAO,CAKjB"}
+131
View File
@@ -0,0 +1,131 @@
"use strict";
exports.__esModule = true;
exports.getLocalName = getLocalName;
exports.isElement = isElement;
exports.isHTMLTableCaptionElement = isHTMLTableCaptionElement;
exports.isHTMLInputElement = isHTMLInputElement;
exports.isHTMLOptGroupElement = isHTMLOptGroupElement;
exports.isHTMLSelectElement = isHTMLSelectElement;
exports.isHTMLTableElement = isHTMLTableElement;
exports.isHTMLTextAreaElement = isHTMLTextAreaElement;
exports.safeWindow = safeWindow;
exports.isHTMLFieldSetElement = isHTMLFieldSetElement;
exports.isHTMLLegendElement = isHTMLLegendElement;
exports.isHTMLSlotElement = isHTMLSlotElement;
exports.isSVGElement = isSVGElement;
exports.isSVGSVGElement = isSVGSVGElement;
exports.isSVGTitleElement = isSVGTitleElement;
exports.queryIdRefs = queryIdRefs;
exports.hasAnyConcreteRoles = hasAnyConcreteRoles;
var _getRole = _interopRequireDefault(require("./getRole"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Safe Element.localName for all supported environments
* @param element
*/
function getLocalName(element) {
var _element$localName;
return (// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
(_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : // eslint-disable-next-line no-restricted-properties -- required for the fallback
element.tagName.toLowerCase()
);
}
function isElement(node) {
return node !== null && node.nodeType === node.ELEMENT_NODE;
}
function isHTMLTableCaptionElement(node) {
return isElement(node) && getLocalName(node) === "caption";
}
function isHTMLInputElement(node) {
return isElement(node) && getLocalName(node) === "input";
}
function isHTMLOptGroupElement(node) {
return isElement(node) && getLocalName(node) === "optgroup";
}
function isHTMLSelectElement(node) {
return isElement(node) && getLocalName(node) === "select";
}
function isHTMLTableElement(node) {
return isElement(node) && getLocalName(node) === "table";
}
function isHTMLTextAreaElement(node) {
return isElement(node) && getLocalName(node) === "textarea";
}
function safeWindow(node) {
var _ref = node.ownerDocument === null ? node : node.ownerDocument,
defaultView = _ref.defaultView;
if (defaultView === null) {
throw new TypeError("no window available");
}
return defaultView;
}
function isHTMLFieldSetElement(node) {
return isElement(node) && getLocalName(node) === "fieldset";
}
function isHTMLLegendElement(node) {
return isElement(node) && getLocalName(node) === "legend";
}
function isHTMLSlotElement(node) {
return isElement(node) && getLocalName(node) === "slot";
}
function isSVGElement(node) {
return isElement(node) && node.ownerSVGElement !== undefined;
}
function isSVGSVGElement(node) {
return isElement(node) && getLocalName(node) === "svg";
}
function isSVGTitleElement(node) {
return isSVGElement(node) && getLocalName(node) === "title";
}
/**
*
* @param {Node} node -
* @param {string} attributeName -
* @returns {Element[]} -
*/
function queryIdRefs(node, attributeName) {
if (isElement(node) && node.hasAttribute(attributeName)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check
var ids = node.getAttribute(attributeName).split(" ");
return ids.map(function (id) {
return node.ownerDocument.getElementById(id);
}).filter(function (element) {
return element !== null;
} // TODO: why does this not narrow?
);
}
return [];
}
function hasAnyConcreteRoles(node, roles) {
if (isElement(node)) {
return roles.indexOf((0, _getRole.default)(node)) !== -1;
}
return false;
}
//# sourceMappingURL=util.js.map
File diff suppressed because one or more lines are too long
+92
View File
@@ -0,0 +1,92 @@
import getRole from "./getRole.mjs";
/**
* Safe Element.localName for all supported environments
* @param element
*/
export function getLocalName(element) {
var _element$localName;
return (// eslint-disable-next-line no-restricted-properties -- actual guard for environments without localName
(_element$localName = element.localName) !== null && _element$localName !== void 0 ? _element$localName : // eslint-disable-next-line no-restricted-properties -- required for the fallback
element.tagName.toLowerCase()
);
}
export function isElement(node) {
return node !== null && node.nodeType === node.ELEMENT_NODE;
}
export function isHTMLTableCaptionElement(node) {
return isElement(node) && getLocalName(node) === "caption";
}
export function isHTMLInputElement(node) {
return isElement(node) && getLocalName(node) === "input";
}
export function isHTMLOptGroupElement(node) {
return isElement(node) && getLocalName(node) === "optgroup";
}
export function isHTMLSelectElement(node) {
return isElement(node) && getLocalName(node) === "select";
}
export function isHTMLTableElement(node) {
return isElement(node) && getLocalName(node) === "table";
}
export function isHTMLTextAreaElement(node) {
return isElement(node) && getLocalName(node) === "textarea";
}
export function safeWindow(node) {
var _ref = node.ownerDocument === null ? node : node.ownerDocument,
defaultView = _ref.defaultView;
if (defaultView === null) {
throw new TypeError("no window available");
}
return defaultView;
}
export function isHTMLFieldSetElement(node) {
return isElement(node) && getLocalName(node) === "fieldset";
}
export function isHTMLLegendElement(node) {
return isElement(node) && getLocalName(node) === "legend";
}
export function isHTMLSlotElement(node) {
return isElement(node) && getLocalName(node) === "slot";
}
export function isSVGElement(node) {
return isElement(node) && node.ownerSVGElement !== undefined;
}
export function isSVGSVGElement(node) {
return isElement(node) && getLocalName(node) === "svg";
}
export function isSVGTitleElement(node) {
return isSVGElement(node) && getLocalName(node) === "title";
}
/**
*
* @param {Node} node -
* @param {string} attributeName -
* @returns {Element[]} -
*/
export function queryIdRefs(node, attributeName) {
if (isElement(node) && node.hasAttribute(attributeName)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- safe due to hasAttribute check
var ids = node.getAttribute(attributeName).split(" ");
return ids.map(function (id) {
return node.ownerDocument.getElementById(id);
}).filter(function (element) {
return element !== null;
} // TODO: why does this not narrow?
);
}
return [];
}
export function hasAnyConcreteRoles(node, roles) {
if (isElement(node)) {
return roles.indexOf(getRole(node)) !== -1;
}
return false;
}
//# sourceMappingURL=util.mjs.map
File diff suppressed because one or more lines are too long
+122
View File
@@ -0,0 +1,122 @@
{
"_from": "dom-accessibility-api@^0.5.6",
"_id": "dom-accessibility-api@0.5.7",
"_inBundle": false,
"_integrity": "sha512-ml3lJIq9YjUfM9TUnEPvEYWFSwivwIGBPKpewX7tii7fwCazA8yCioGdqQcNsItPpfFvSJ3VIdMQPj60LJhcQA==",
"_location": "/dom-accessibility-api",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "dom-accessibility-api@^0.5.6",
"name": "dom-accessibility-api",
"escapedName": "dom-accessibility-api",
"rawSpec": "^0.5.6",
"saveSpec": null,
"fetchSpec": "^0.5.6"
},
"_requiredBy": [
"/@testing-library/dom",
"/@testing-library/jest-dom"
],
"_resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.7.tgz",
"_shasum": "8c2aa6325968f2933160a0b7dbb380893ddf3e7d",
"_spec": "dom-accessibility-api@^0.5.6",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/@testing-library/jest-dom",
"bugs": {
"url": "https://github.com/eps1lon/dom-accessibility-api/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Implements https://w3c.github.io/accname/",
"devDependencies": {
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/preset-env": "^7.14.4",
"@babel/preset-typescript": "^7.13.0",
"@changesets/changelog-github": "^0.4.0",
"@changesets/cli": "^2.16.0",
"@testing-library/dom": "^8.0.0",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"concurrently": "^6.2.0",
"cross-env": "^7.0.3",
"cypress": "^8.0.0",
"eslint": "^7.27.0",
"eslint-plugin-jest": "^24.3.6",
"jest": "^27.0.3",
"jest-diff": "^27.0.2",
"jest-environment-jsdom": "^27.0.3",
"jest-junit": "^12.1.0",
"js-yaml": "^4.1.0",
"jsdom": "^16.6.0",
"minimatch": "^3.0.4",
"mocha": "^9.0.0",
"mocha-sugar-free": "^1.4.0",
"prettier": "^2.3.0",
"q": "^1.5.1",
"request": "^2.88",
"request-promise-native": "^1.0.9",
"rimraf": "^3.0.2",
"serve": "^12.0.0",
"typescript": "^4.3.2"
},
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"files": [
".browserslistrc",
"dist/"
],
"homepage": "https://github.com/eps1lon/dom-accessibility-api#readme",
"keywords": [
"accessibility",
"ARIA",
"accname"
],
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"name": "dom-accessibility-api",
"prettier": {
"useTabs": true
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eps1lon/dom-accessibility-api.git"
},
"resolutions": {
"**/kind-of": "^6.0.3",
"**/minimist": "^1.2.2"
},
"scripts": {
"build": "yarn build:clean && yarn build:source && yarn build:source:cjs && yarn build:types",
"build:clean": "rimraf dist",
"build:source": "cross-env BABEL_ENV=esm babel sources --extensions \".ts\" --ignore \"**/__tests__/**/*\" --out-dir dist/ --out-file-extension=.mjs --source-maps",
"build:source:cjs": "cross-env BABEL_ENV=cjs babel sources --extensions \".ts\" --ignore \"**/__tests__/**/*\" --out-dir dist/ --out-file-extension=.js --source-maps",
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
"format": "prettier \"**/*.{json,js,md,ts,yml}\" --write --ignore-path .prettierignore",
"lint": "eslint --report-unused-disable-directives \"{scripts,sources}/**/*.{js,ts}\"",
"release": "yarn build && yarn changeset publish",
"test": "jest --config scripts/jest/jest.config.js",
"test:ci": "jest --ci --config scripts/jest/jest.ci.config.js --runInBand",
"test:coverage": "jest --config scripts/jest/jest.coverage.config.js",
"test:types": "tsc -p tsconfig.json --noEmit",
"test:wpt:browser": "concurrently --success first --kill-others \"yarn test:wpt:browser:run\" \"yarn test:wpt:browser:server\"",
"test:wpt:browser:open": "cypress open --project tests",
"test:wpt:browser:run": "cypress run --project tests",
"test:wpt:browser:server": "serve tests/wpt",
"test:wpt:jsdom": "mocha tests/wpt-jsdom/run-wpts.js",
"wpt:init": "git submodule update --init --recursive",
"wpt:reset": "rimraf ./tests/wpt && yarn wpt:init",
"wpt:update": "git submodule update --recursive --remote && cd tests/wpt && python wpt.py manifest --path ../wpt-jsdom/wpt-manifest.json"
},
"type": "commonjs",
"version": "0.5.7"
}