A TypeScript library for calculating the accessible name of HTMLElement
s.
To install accname
with NPM, run:
$ npm install accname
Once installed, import and use accname
as follows:
License: Other
A TypeScript library for calculating the accessible name of HTMLElement
s.
To install accname
with NPM, run:
$ npm install accname
Once installed, import and use accname
as follows:
<input />
Node twice here, adding it to the list of context.visitedNodes
only when it traverses this <input />
for the second time.Each node in the subtree is consulted only once.
. In fact it would appear that no node should ever be visited more than once during accessible name computation, in which case the spec should be re-worded to reflect this.computeTextAlternative()
and ensuring that a node is only processed if it has never been seen before.context.inherited.visitedNodes
and context.inherited.nodesUsed
.See #32
Elements marked explicitly as comboboxes (role=”combobox”
) are not currently included in accessible names produced by accname
's algorithm.
The Web Platform Tests for accname were run on accname
using the AccName Comparison app. In addition to this, the Comparison app was used to compare implementations on 29,846 nodes spanning 16 different web-pages.
These tests & comparisons revealed a number of issues with accname
that are detailed in this document.
Thank you for writing this library! I may have found an issue, though, with shadow DOM support.
For an element containing a shadow root, e.g.:
<button>
<x-component>
#shadow-root
hello world
</x-component>
</button>
In this example, the accessible name contains "hello world". But accname
does not recognize this text, instead returning an empty string. Here is a minimal repro.
See #32
Some Web Platform Tests expect Nodes that are aria-owned by the current node
to be treated in the same way as descendants are in 2F.
Some Web Platform Tests that revealed this issue:
http://wpt.live/accname/name_file-label-owned-combobox-manual.html
http://wpt.live/accname/name_file-label-owned-combobox-owned-listbox-manual.html
See #32
accname
fails many WPTs because it does not ignore elements with role="menu"
.accname
passing at least 10 more WPTs.data:text/html,<button title="accname"></button>
Firefox and Chrome both give an accname of accname
but we give ""
. Presumably some rule before 2I is returning ""
rather than null
17/116 unit tests currently fail on Internet Explorer.
e.g.
fit('understands label for', () => {
render(
html`
<button id="foo">text</button>
<label for="foo">bar</label>`,
container);
const elem = document.getElementById('foo');
expect(computeTextAlternative(elem!)).toBe('bar');
});
This passes on chrome and firefox but IE gives elem
an accessible name of text
.
See #32
accname
is adding CSS pseudo-element content to the accessible name even when the content is non-textual. This has materialised on multiple occasions as url(...)
. Rule 2F should take some measure to ensure that such content is textual.See #32
accname
often includes an empty white square character (□) when other implementations do not. This could be filtered out before the output string is returned.See #32
Elements that are inline should be handled differently to those that are block-level in step 2F. More specifically, block-level Elements should be concatenated to the accumulated
text in a space-separated manner by rule 2F, inline Elements should be concatenated without spaces.
The same applies for CSS pseudo-elements that are block-level or inline.
current node
conditionally allows name from content.accname
.If no element has the ac
attribute, the error shown in the UI is
Error: Protocol error (DOM.describeNode): Could not find node with given id
I think this will be the most common user error (I've made it at least twice!) so a more friendly error message would be useful
See #32
accname
to behave more similarly to existing implementations.See #32
accname
doesn’t recognise <title>
s as labels for <svg>
elements. The rest of the implementations do. This check could be added to rule 2D.accname
's accuracy calculated every time a PR is made.master
to get a performance diff for each PR.See, for example: https://github.com/marketplace/actions/comment-on-pr
See #32
See #32
<option>
elements could be considered direct label
s in cases where they are labelling a <select>
(i.e because they are selected). As it stands these <option>
labels often aren’t visible as they are part of a pop-up menu, and so they are blocked by 2A.We should make sure that we can run all the unit tests when mergin a PR to avoid accidentally breaking things.
Ideally we can figure out how to run them on different browsers too.
See #32
The empty string is being returned by step 2F in cases when an Element that allows name from content has no descendants. Instead, other steps (such as 2I) should be considered. For example:
<input type="checkbox" title="foo">
<input>
should have an accessible name of ”foo” here, but accname is returning ””.
This issue is also referenced in #19
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.