Given
<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 and therefore the accessible name is now computed using <label />
elements if they exists.
In this example the accessible name is "Output Label"
.
Source:
-const [item] = list;
+const item = list[0];
Transpiled:
-var _trim$split = list.trim().split(" "),
-_trim$split2 = _slicedToArray(_trim$split, 1),
-item = _trim$split2[0]
+var item = list[0];
Given
<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 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.
3866289
#442 Thanks @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:
<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:
<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.
Previously <img />
would be treated the same as <img alt />
.
<img />
is now treated as role="img"
as specified.
96d4438
#436 Thanks @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 it should have role="presentation"
with no ARIA attributes or role="img"
otherwise.
Prefer input value
when type
is reset
or submit
:
<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"
.
fcc66ae
#394 Thanks @marcosvega91! - Ignore title
attribute if it is empty.Previously <button title="">Hello, Dave!</button>
would wrongly compute an empty name.
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:
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:
computeAccessibleName(element, {
computedStyleSupportsPseudoElements: true
});
computeAccessibleName(element, {
getComputedStyle: (element, pseudoElement) => {
// custom implementation
}
});
Also affects Edge < 18 and Firefox < 56.
We only stopped testing. Probability of breakage should be very low.
New policy:
Only active node versions are supported. Inactive node versions can stop working in a SemVer MINOR release.
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).
Fixes <h1>Hello {name}!</h1>
in react
computing "Hello name !"
instead of Hello name!
.
<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
Switched from
for-of
to .forEach
or a basic for
looparray.push(...otherArray)
to push.apply(array, otherArray)
This removed a bunch of babel junk that wasn't needed.
<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
Fixes a crash when using ES modules in Node.
7f1ada0
: Internal polisheb86842
: Add option to mock window.getComputedStyleThis option has two use cases in mind:
window.getComputedStyle
. We don't implement any because the returned CSSStyleDeclaration
is only live in a browser. jsdom
does not implement live declarations.