Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
aria-voyager
Advanced tools
A framework agnostic / universal package that implements navigation patterns for various aria roles and features
Canoe vessel that navigates your aria.
A framework agnostic / universal package that implements navigation patterns for various aria roles and features.
... and this library will make it interactive, according to applicable ARIA patterns. This library does not apply styling, it will operate on the accessibility tree.
See hokulea/aria-voyager
for a
full list of supported features.
pnpm add aria-voyager
Listbox
Bring your own markup in at first, here is an example markup for a list:
<ul role="listbox">
<li role="option">Banana</li>
<li role="option" aria-selected="true">Apple</li>
<li role="option">Mango</li>
</ul>
To make it interactive, create a new Listbox
instance pointing it at your element.
import { Listbox } from 'aria-voyager';
const listElement = document.querySelector('[role="listbox"]');
new Listbox(listElement);
That is already enough to start making your listbox interactive. It will read the options from the provided HTML.
Listbox
accepts options as second parameter:
import type { EmitStrategy, UpdateStrategy } from 'aria-voyager';
interface ListboxOptions {
updater?: UpdateStrategy;
emitter?: EmitStrategy;
}
Menu
Bring your own markup in at first, here is an example markup for a menu:
<div role="menu">
<button role="menuitem">Version Info</button>
<a role="menuitem" href="https://github.com/hokulea/aria-voyager" target="_blank">Github</a>
<button role="menuitem" popovertarget="authormenu">Author</button>
<div role="menu" id="authormenu" popover>
<a role="menuitem" href="https://gos.si" target="_blank">Homepage</a>
<a role="menuitem" href="https://github.com" target="_blank">Github</a>
</div>
</div>
To make it interactive, create a new Menu
instance pointing it at your element.
import { Menu } from 'aria-voyager';
const menuElement = document.querySelector('[role="menu"]');
new Menu(menuElement);
Menu
accepts options as second parameter:
import type { EmitStrategy, UpdateStrategy } from 'aria-voyager';
interface MenuOptions {
updater?: UpdateStrategy;
emitter?: EmitStrategy;
}
Tablist
Bring your own markup in at first, here is an example markup for a list:
<div>
<ul role="tablist">
<li role="tab" id="tab-1" aria-controls="panel-1">Tab 1</li>
<li role="tab" id="tab-2" aria-controls="panel-2">Tab 2</li>
<li role="tab" id="tab-3" aria-controls="panel-3">Tab 3</li>
</ul>
<div role="tabpanel" id="panel-1" aria-labelledby="tab-1">
Contents Panel 1
</div>
<div role="tabpanel" id="panel-2" aria-labelledby="tab-2">
Contents Panel 2
</div>
<div role="tabpanel" id="panel-3" aria-labelledby="tab-3">
Contents Panel 3
</div>
<div>
To make it interactive, create a new Tablist
instance pointing it at your tablist
element.
import { Tablist } from 'aria-voyager';
const tablistElement = document.querySelector('[role="tablist"]');
new Tablist(tablistElement);
That is already enough to start making your listbox interactive. It will read the options from the provided HTML.
Tablist
accepts options as second parameter:
import type { EmitStrategy, UpdateStrategy, TablistBehavior } from 'aria-voyager';
interface TablistOptions {
updater?: UpdateStrategy;
emitter?: EmitStrategy;
behavior?: TablistBehavior;
}
aria-voyager
supports the concept of input (updater) and output (emitter)
through exchangeable strategies.
The job of an updater is to tell the controls, when new updates are available, such as selection has changed, new elements were added or existing ones removed from the DOM.
By default, aria-voyager
uses the DOMOberserverUpdateStrategy
which - as the
name suggests - observes the DOM for changes. So the controls stay updated from
your changes to the DOM.
That might be inefficient given different rendering strategies in the various frontend frameworks flush changes more frequent than what seems the right dosis for such a DOMObserver.
To optimize this, there is a blank ReactiveUpdateStrategy
, which you can extend
to write a framework integration. With that you can hook into the reactivity
system of your framework and tell aria-voyager
when updates are available.
Controls are interactive elements, so you also want to know when things are happening to react on user interactions.
Emitters are the way to receive those events. aria-voyager
ships with two
strategies, that emit changes:
IndexEmitStrategy
which tells you the indexes of the elements, based on the
index of an elements amongst its children in the DOM.
ItemEmitStrategy
which tells you which elements are changed.
Both are suited to write a framework integration to bridge between DOM and your application code.
FAQs
A framework agnostic / universal package that implements navigation patterns for various aria roles and features
The npm package aria-voyager receives a total of 413 weekly downloads. As such, aria-voyager popularity was classified as not popular.
We found that aria-voyager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.