|
|
|
|
@ -4,7 +4,8 @@ import { regex_whitespaces } from '../../utils/patterns.js';
|
|
|
|
|
const aria_roles = roles_map.keys();
|
|
|
|
|
const abstract_roles = new Set(aria_roles.filter((role) => roles_map.get(role).abstract));
|
|
|
|
|
const non_abstract_roles = aria_roles.filter((name) => !abstract_roles.has(name));
|
|
|
|
|
const non_interactive_roles = new Set(non_abstract_roles
|
|
|
|
|
const non_interactive_roles = new Set(
|
|
|
|
|
non_abstract_roles
|
|
|
|
|
.filter((name) => {
|
|
|
|
|
const role = roles_map.get(name);
|
|
|
|
|
return (
|
|
|
|
|
@ -13,15 +14,23 @@ const non_interactive_roles = new Set(non_abstract_roles
|
|
|
|
|
// focusable tabpanel elements are recommended if any panels in a set contain content where the first element in the panel is not focusable.
|
|
|
|
|
// 'generic' is meant to have no semantic meaning.
|
|
|
|
|
!['toolbar', 'tabpanel', 'generic'].includes(name) &&
|
|
|
|
|
!role.superClass.some((classes) => classes.includes('widget')));
|
|
|
|
|
!role.superClass.some((classes) => classes.includes('widget'))
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
.concat(
|
|
|
|
|
// The `progressbar` is descended from `widget`, but in practice, its
|
|
|
|
|
// value is always `readonly`, so we treat it as a non-interactive role.
|
|
|
|
|
'progressbar'));
|
|
|
|
|
const interactive_roles = new Set(non_abstract_roles.filter((name) => !non_interactive_roles.has(name) &&
|
|
|
|
|
'progressbar'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
const interactive_roles = new Set(
|
|
|
|
|
non_abstract_roles.filter(
|
|
|
|
|
(name) =>
|
|
|
|
|
!non_interactive_roles.has(name) &&
|
|
|
|
|
// 'generic' is meant to have no semantic meaning.
|
|
|
|
|
name !== 'generic'));
|
|
|
|
|
name !== 'generic'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {ARIARoleDefinitionKey} role
|
|
|
|
|
@ -64,10 +73,8 @@ export function is_hidden_from_screen_reader(tag_name, attribute_map) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const aria_hidden = attribute_map.get('aria-hidden');
|
|
|
|
|
if (!aria_hidden)
|
|
|
|
|
return false;
|
|
|
|
|
if (!aria_hidden.is_static)
|
|
|
|
|
return true;
|
|
|
|
|
if (!aria_hidden) return false;
|
|
|
|
|
if (!aria_hidden.is_static) return true;
|
|
|
|
|
const aria_hidden_value = aria_hidden.get_static_value();
|
|
|
|
|
return aria_hidden_value === true || aria_hidden_value === 'true';
|
|
|
|
|
}
|
|
|
|
|
@ -110,8 +117,14 @@ elementRoles.entries().forEach(([schema, roles]) => {
|
|
|
|
|
interactive_element_role_schemas.push(schema);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const interactive_ax_objects = new Set([...AXObjects.keys()].filter((name) => AXObjects.get(name).type === 'widget'));
|
|
|
|
|
const non_interactive_ax_objects = new Set([...AXObjects.keys()].filter((name) => ['windows', 'structure'].includes(AXObjects.get(name).type)));
|
|
|
|
|
const interactive_ax_objects = new Set(
|
|
|
|
|
[...AXObjects.keys()].filter((name) => AXObjects.get(name).type === 'widget')
|
|
|
|
|
);
|
|
|
|
|
const non_interactive_ax_objects = new Set(
|
|
|
|
|
[...AXObjects.keys()].filter((name) =>
|
|
|
|
|
['windows', 'structure'].includes(AXObjects.get(name).type)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @type {ARIARoleRelationConcept[]}
|
|
|
|
|
@ -139,14 +152,11 @@ elementAXObjects.entries().forEach(([schema, ax_object]) => {
|
|
|
|
|
* @param {Map<string, Attribute>} attribute_map
|
|
|
|
|
*/
|
|
|
|
|
function match_schema(schema, tag_name, attribute_map) {
|
|
|
|
|
if (schema.name !== tag_name)
|
|
|
|
|
return false;
|
|
|
|
|
if (!schema.attributes)
|
|
|
|
|
return true;
|
|
|
|
|
if (schema.name !== tag_name) return false;
|
|
|
|
|
if (!schema.attributes) return true;
|
|
|
|
|
return schema.attributes.every((schema_attribute) => {
|
|
|
|
|
const attribute = attribute_map.get(schema_attribute.name);
|
|
|
|
|
if (!attribute)
|
|
|
|
|
return false;
|
|
|
|
|
if (!attribute) return false;
|
|
|
|
|
if (schema_attribute.value && schema_attribute.value !== attribute.get_static_value()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@ -155,9 +165,9 @@ function match_schema(schema, tag_name, attribute_map) {
|
|
|
|
|
}
|
|
|
|
|
export var ElementInteractivity;
|
|
|
|
|
(function (ElementInteractivity) {
|
|
|
|
|
ElementInteractivity["Interactive"] = "interactive";
|
|
|
|
|
ElementInteractivity["NonInteractive"] = "non-interactive";
|
|
|
|
|
ElementInteractivity["Static"] = "static";
|
|
|
|
|
ElementInteractivity['Interactive'] = 'interactive';
|
|
|
|
|
ElementInteractivity['NonInteractive'] = 'non-interactive';
|
|
|
|
|
ElementInteractivity['Static'] = 'static';
|
|
|
|
|
})(ElementInteractivity || (ElementInteractivity = {}));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -166,17 +176,31 @@ export var ElementInteractivity;
|
|
|
|
|
* @returns {import("C:/repos/svelte/svelte/a11y.ts-to-jsdoc").ElementInteractivity}
|
|
|
|
|
*/
|
|
|
|
|
export function element_interactivity(tag_name, attribute_map) {
|
|
|
|
|
if (interactive_element_role_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))) {
|
|
|
|
|
if (
|
|
|
|
|
interactive_element_role_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))
|
|
|
|
|
) {
|
|
|
|
|
return ElementInteractivity.Interactive;
|
|
|
|
|
}
|
|
|
|
|
if (tag_name !== 'header' &&
|
|
|
|
|
non_interactive_element_role_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))) {
|
|
|
|
|
if (
|
|
|
|
|
tag_name !== 'header' &&
|
|
|
|
|
non_interactive_element_role_schemas.some((schema) =>
|
|
|
|
|
match_schema(schema, tag_name, attribute_map)
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
return ElementInteractivity.NonInteractive;
|
|
|
|
|
}
|
|
|
|
|
if (interactive_element_ax_object_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))) {
|
|
|
|
|
if (
|
|
|
|
|
interactive_element_ax_object_schemas.some((schema) =>
|
|
|
|
|
match_schema(schema, tag_name, attribute_map)
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
return ElementInteractivity.Interactive;
|
|
|
|
|
}
|
|
|
|
|
if (non_interactive_element_ax_object_schemas.some((schema) => match_schema(schema, tag_name, attribute_map))) {
|
|
|
|
|
if (
|
|
|
|
|
non_interactive_element_ax_object_schemas.some((schema) =>
|
|
|
|
|
match_schema(schema, tag_name, attribute_map)
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
return ElementInteractivity.NonInteractive;
|
|
|
|
|
}
|
|
|
|
|
return ElementInteractivity.Static;
|
|
|
|
|
@ -216,10 +240,15 @@ export function is_static_element(tag_name, attribute_map) {
|
|
|
|
|
*/
|
|
|
|
|
export function is_semantic_role_element(role, tag_name, attribute_map) {
|
|
|
|
|
for (const [schema, ax_object] of elementAXObjects.entries()) {
|
|
|
|
|
if (schema.name === tag_name &&
|
|
|
|
|
if (
|
|
|
|
|
schema.name === tag_name &&
|
|
|
|
|
(!schema.attributes ||
|
|
|
|
|
schema.attributes.every((attr) => attribute_map.has(attr.name) &&
|
|
|
|
|
attribute_map.get(attr.name).get_static_value() === attr.value))) {
|
|
|
|
|
schema.attributes.every(
|
|
|
|
|
(attr) =>
|
|
|
|
|
attribute_map.has(attr.name) &&
|
|
|
|
|
attribute_map.get(attr.name).get_static_value() === attr.value
|
|
|
|
|
))
|
|
|
|
|
) {
|
|
|
|
|
for (const name of ax_object) {
|
|
|
|
|
const roles = AXObjectRoles.get(name);
|
|
|
|
|
if (roles) {
|
|
|
|
|
@ -305,8 +334,7 @@ const autofill_contact_field_name_tokens = new Set([
|
|
|
|
|
export function is_valid_autocomplete(autocomplete) {
|
|
|
|
|
if (autocomplete === true) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (!autocomplete) {
|
|
|
|
|
} else if (!autocomplete) {
|
|
|
|
|
return true; // dynamic value
|
|
|
|
|
}
|
|
|
|
|
const tokens = autocomplete.trim().toLowerCase().split(regex_whitespaces);
|
|
|
|
|
@ -318,15 +346,13 @@ export function is_valid_autocomplete(autocomplete) {
|
|
|
|
|
}
|
|
|
|
|
if (autofill_field_name_tokens.has(tokens[0])) {
|
|
|
|
|
tokens.shift();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
if (contact_type_tokens.has(tokens[0])) {
|
|
|
|
|
tokens.shift();
|
|
|
|
|
}
|
|
|
|
|
if (autofill_contact_field_name_tokens.has(tokens[0])) {
|
|
|
|
|
tokens.shift();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -335,7 +361,3 @@ export function is_valid_autocomplete(autocomplete) {
|
|
|
|
|
}
|
|
|
|
|
return tokens.length === 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|