mirror of https://github.com/sveltejs/svelte
parent
2d0e13a504
commit
ce88b9aa9d
@ -1,48 +0,0 @@
|
||||
import Element from '../nodes/Element';
|
||||
|
||||
const interactiveInputTypes = new Set([
|
||||
'submit',
|
||||
'reset',
|
||||
'image',
|
||||
'button',
|
||||
'radio',
|
||||
'checkbox'
|
||||
]);
|
||||
|
||||
export const is_interactive_element: (element: Element) => boolean = function (
|
||||
element
|
||||
) {
|
||||
if (element.name === 'details') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element.name === 'summary') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element.name === 'a') {
|
||||
return element.attributes.some((attr) => attr.name === 'href');
|
||||
}
|
||||
|
||||
if (element.name === 'button') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element.name === 'input') {
|
||||
const typeValue = element.attributes.find((attr) => attr.name === 'type');
|
||||
if (typeValue) {
|
||||
return interactiveInputTypes.has((typeValue.get_static_value() || '').toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (element.name === 'option') {
|
||||
return element.attributes.some((attr) => attr.name === 'value');
|
||||
}
|
||||
|
||||
if (element.name === 'dialog') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@ -1,18 +0,0 @@
|
||||
import { ARIARoleDefintionKey, roles as rolesMap } from 'aria-query';
|
||||
|
||||
const roles = [...rolesMap.keys()];
|
||||
const _interactiveRoles = roles.filter(
|
||||
(name) =>
|
||||
!rolesMap.get(name).abstract &&
|
||||
rolesMap.get(name).superClass.some((c) => c.includes('widget'))
|
||||
);
|
||||
|
||||
// 'toolbar' does not descend from widget, but it does support
|
||||
// aria-activedescendant, thus in practice we treat it as a widget.
|
||||
_interactiveRoles.push('toolbar');
|
||||
|
||||
const interactiveRoles = new Set(_interactiveRoles);
|
||||
|
||||
export const is_interactive_roles: (role: string) => boolean = (role) => {
|
||||
return interactiveRoles.has(role as ARIARoleDefintionKey);
|
||||
};
|
||||
Loading…
Reference in new issue