@markuplint/ml-spec 4.10.1 → 4.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.ja.md +253 -0
- package/ARCHITECTURE.md +253 -0
- package/CHANGELOG.md +3 -3
- package/README.md +4 -186
- package/SKILL.md +116 -0
- package/docs/aria-algorithms.ja.md +651 -0
- package/docs/aria-algorithms.md +651 -0
- package/docs/html-algorithms.ja.md +469 -0
- package/docs/html-algorithms.md +469 -0
- package/docs/maintenance.ja.md +340 -0
- package/docs/maintenance.md +340 -0
- package/docs/spec-resolution.ja.md +540 -0
- package/docs/spec-resolution.md +551 -0
- package/docs/type-definitions.ja.md +561 -0
- package/docs/type-definitions.md +561 -0
- package/lib/algorithm/aria/accname-computation.d.ts +7 -0
- package/lib/algorithm/aria/accname-computation.js +7 -0
- package/lib/algorithm/aria/aria-specs.d.ts +7 -0
- package/lib/algorithm/aria/aria-specs.js +7 -0
- package/lib/algorithm/aria/get-aria.d.ts +12 -0
- package/lib/algorithm/aria/get-aria.js +12 -0
- package/lib/algorithm/aria/get-computed-aria-props.d.ts +22 -0
- package/lib/algorithm/aria/get-computed-aria-props.js +10 -0
- package/lib/algorithm/aria/get-computed-role.d.ts +12 -0
- package/lib/algorithm/aria/get-computed-role.js +12 -0
- package/lib/algorithm/aria/get-implicit-role.d.ts +18 -0
- package/lib/algorithm/aria/get-implicit-role.js +18 -0
- package/lib/algorithm/aria/get-permitted-roles.d.ts +9 -0
- package/lib/algorithm/aria/get-permitted-roles.js +9 -0
- package/lib/algorithm/aria/get-role-spec.d.ts +11 -0
- package/lib/algorithm/aria/get-role-spec.js +11 -0
- package/lib/algorithm/aria/has-required-owned-elements.d.ts +23 -0
- package/lib/algorithm/aria/has-required-owned-elements.js +23 -0
- package/lib/algorithm/aria/is-exposed.d.ts +7 -4
- package/lib/algorithm/aria/is-exposed.js +7 -4
- package/lib/algorithm/aria/is-presentational.d.ts +8 -0
- package/lib/algorithm/aria/is-presentational.js +8 -0
- package/lib/algorithm/aria/matches-context-role.d.ts +11 -0
- package/lib/algorithm/aria/matches-context-role.js +11 -0
- package/lib/algorithm/html/content-model-category-to-tag-names.d.ts +9 -0
- package/lib/algorithm/html/content-model-category-to-tag-names.js +9 -0
- package/lib/algorithm/html/get-content-model.d.ts +9 -0
- package/lib/algorithm/html/get-content-model.js +9 -0
- package/lib/algorithm/html/get-selectors-by-content-model-category.d.ts +8 -0
- package/lib/algorithm/html/get-selectors-by-content-model-category.js +8 -0
- package/lib/algorithm/html/is-nothing-content-model.d.ts +7 -0
- package/lib/algorithm/html/is-nothing-content-model.js +7 -0
- package/lib/algorithm/html/is-palpable-elements.d.ts +13 -0
- package/lib/algorithm/html/is-palpable-elements.js +13 -0
- package/lib/algorithm/html/is-void-element.d.ts +9 -0
- package/lib/algorithm/html/is-void-element.js +9 -0
- package/lib/algorithm/html/may-be-focusable.d.ts +10 -0
- package/lib/algorithm/html/may-be-focusable.js +10 -0
- package/lib/types/index.d.ts +54 -0
- package/lib/utils/aria-version.d.ts +6 -0
- package/lib/utils/aria-version.js +6 -0
- package/lib/utils/get-attr-specs-spec.d.ts +18 -0
- package/lib/utils/get-attr-specs-spec.js +18 -0
- package/lib/utils/get-attr-specs.d.ts +9 -0
- package/lib/utils/get-attr-specs.js +9 -0
- package/lib/utils/get-spec-by-tag-name.d.ts +11 -0
- package/lib/utils/get-spec-by-tag-name.js +11 -0
- package/lib/utils/get-spec.d.ts +11 -1
- package/lib/utils/get-spec.js +10 -0
- package/lib/utils/resolve-namespace.d.ts +13 -0
- package/lib/utils/resolve-namespace.js +10 -0
- package/lib/utils/schema-to-spec.d.ts +5 -2
- package/lib/utils/schema-to-spec.js +5 -2
- package/lib/utils/validate-aria-version.d.ts +7 -0
- package/lib/utils/validate-aria-version.js +7 -0
- package/package.json +6 -6
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { ariaSpecs as _ariaSpecs } from './aria-specs.js';
|
|
2
2
|
import { getComputedRole } from './get-computed-role.js';
|
|
3
|
+
/**
|
|
4
|
+
* Computes the resolved ARIA properties for an element based on its computed role.
|
|
5
|
+
* Resolves property values by checking explicit `aria-*` attributes first,
|
|
6
|
+
* then equivalent HTML attributes, and finally falling back to spec-defined defaults.
|
|
7
|
+
*
|
|
8
|
+
* @param specs - The full markup language specification
|
|
9
|
+
* @param el - The DOM element to compute ARIA properties for
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @returns A record of ARIA property names to their computed property details, or an empty record if the element has no computed role
|
|
12
|
+
*/
|
|
3
13
|
export function getComputedAriaProps(specs,
|
|
4
14
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
5
15
|
el, version) {
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Computes the final ARIA role for an element according to the WAI-ARIA specification,
|
|
4
|
+
* applying the Presentational Roles Conflict Resolution algorithm. This considers
|
|
5
|
+
* the explicit role, implicit role, required context roles, focusability,
|
|
6
|
+
* global ARIA properties, and SVG accessibility tree inclusion rules.
|
|
7
|
+
*
|
|
8
|
+
* @param specs - The full markup language specification
|
|
9
|
+
* @param el - The DOM element to compute the role for
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @param assumeSingleNode - When true, skips parent context validation and assumes the element is a standalone fragment
|
|
12
|
+
* @returns The computed role result including the resolved role spec (or null) and any error type
|
|
13
|
+
*/
|
|
2
14
|
export declare function getComputedRole(specs: MLMLSpec, el: Element, version: ARIAVersion, assumeSingleNode?: boolean): ComputedRole;
|
|
@@ -8,6 +8,18 @@ import { getNonPresentationalAncestor } from './get-non-presentational-ancestor.
|
|
|
8
8
|
import { isRequiredOwnedElement } from './has-required-owned-elements.js';
|
|
9
9
|
import { matchesContextRole } from './matches-context-role.js';
|
|
10
10
|
import { mayBeFocusable } from '../html/may-be-focusable.js';
|
|
11
|
+
/**
|
|
12
|
+
* Computes the final ARIA role for an element according to the WAI-ARIA specification,
|
|
13
|
+
* applying the Presentational Roles Conflict Resolution algorithm. This considers
|
|
14
|
+
* the explicit role, implicit role, required context roles, focusability,
|
|
15
|
+
* global ARIA properties, and SVG accessibility tree inclusion rules.
|
|
16
|
+
*
|
|
17
|
+
* @param specs - The full markup language specification
|
|
18
|
+
* @param el - The DOM element to compute the role for
|
|
19
|
+
* @param version - The ARIA specification version to use
|
|
20
|
+
* @param assumeSingleNode - When true, skips parent context validation and assumes the element is a standalone fragment
|
|
21
|
+
* @returns The computed role result including the resolved role spec (or null) and any error type
|
|
22
|
+
*/
|
|
11
23
|
export function getComputedRole(specs,
|
|
12
24
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
13
25
|
el, version, assumeSingleNode = false) {
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { ImplicitRole } from '../../types/aria.js';
|
|
2
2
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Determines the implicit (native) ARIA role for an element based on its tag name,
|
|
5
|
+
* namespace, and any matching conditions defined in the HTML-ARIA spec.
|
|
6
|
+
*
|
|
7
|
+
* @param specs - The full markup language specification
|
|
8
|
+
* @param el - The DOM element to determine the implicit role for
|
|
9
|
+
* @param version - The ARIA specification version to use
|
|
10
|
+
* @returns The computed role result containing the implicit role spec, or null if no corresponding role exists
|
|
11
|
+
*/
|
|
3
12
|
export declare function getImplicitRole(specs: MLMLSpec, el: Element, version: ARIAVersion): ComputedRole;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves the implicit role name string for an element without resolving
|
|
15
|
+
* the full role specification. Returns `false` when no corresponding role exists.
|
|
16
|
+
*
|
|
17
|
+
* @param el - The DOM element to look up the implicit role name for
|
|
18
|
+
* @param version - The ARIA specification version to use
|
|
19
|
+
* @param specs - The full markup language specification
|
|
20
|
+
* @returns The implicit role name string, or `false` if the element has no corresponding role
|
|
21
|
+
*/
|
|
4
22
|
export declare function getImplicitRoleName(el: Element, version: ARIAVersion, specs: MLMLSpec): ImplicitRole;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { getImplicitRole as _getImplicitRole } from './get-implicit-role-spec.js';
|
|
2
2
|
import { getRoleSpec } from './get-role-spec.js';
|
|
3
3
|
import { resolveNamespace } from '../../utils/resolve-namespace.js';
|
|
4
|
+
/**
|
|
5
|
+
* Determines the implicit (native) ARIA role for an element based on its tag name,
|
|
6
|
+
* namespace, and any matching conditions defined in the HTML-ARIA spec.
|
|
7
|
+
*
|
|
8
|
+
* @param specs - The full markup language specification
|
|
9
|
+
* @param el - The DOM element to determine the implicit role for
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @returns The computed role result containing the implicit role spec, or null if no corresponding role exists
|
|
12
|
+
*/
|
|
4
13
|
export function getImplicitRole(specs,
|
|
5
14
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
15
|
el, version) {
|
|
@@ -29,6 +38,15 @@ el, version) {
|
|
|
29
38
|
},
|
|
30
39
|
};
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the implicit role name string for an element without resolving
|
|
43
|
+
* the full role specification. Returns `false` when no corresponding role exists.
|
|
44
|
+
*
|
|
45
|
+
* @param el - The DOM element to look up the implicit role name for
|
|
46
|
+
* @param version - The ARIA specification version to use
|
|
47
|
+
* @param specs - The full markup language specification
|
|
48
|
+
* @returns The implicit role name string, or `false` if the element has no corresponding role
|
|
49
|
+
*/
|
|
32
50
|
export function getImplicitRoleName(
|
|
33
51
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
34
52
|
el, version, specs) {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the list of permitted ARIA roles that may be explicitly assigned
|
|
4
|
+
* to an element, based on its tag name, namespace, and current attribute state.
|
|
5
|
+
*
|
|
6
|
+
* @param el - The DOM element to determine permitted roles for
|
|
7
|
+
* @param version - The ARIA specification version to use
|
|
8
|
+
* @param specs - The full markup language specification
|
|
9
|
+
* @returns The permitted roles specification, which may be a boolean, an array of role names, or an AAM reference
|
|
10
|
+
*/
|
|
2
11
|
export declare function getPermittedRoles(el: Element, version: ARIAVersion, specs: MLMLSpec): readonly {
|
|
3
12
|
readonly name: string;
|
|
4
13
|
readonly deprecated?: boolean;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { getPermittedRoles as _getPermittedRoles } from './get-permitted-roles-spec.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the list of permitted ARIA roles that may be explicitly assigned
|
|
4
|
+
* to an element, based on its tag name, namespace, and current attribute state.
|
|
5
|
+
*
|
|
6
|
+
* @param el - The DOM element to determine permitted roles for
|
|
7
|
+
* @param version - The ARIA specification version to use
|
|
8
|
+
* @param specs - The full markup language specification
|
|
9
|
+
* @returns The permitted roles specification, which may be a boolean, an array of role names, or an AAM reference
|
|
10
|
+
*/
|
|
2
11
|
export function getPermittedRoles(
|
|
3
12
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
13
|
el, version, specs) {
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { ARIAVersion, ARIARoleInSchema, MLMLSpec, ARIARole } from '../../types/index.js';
|
|
2
2
|
import type { NamespaceURI } from '@markuplint/ml-ast';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the full ARIA role specification for a given role name, including
|
|
5
|
+
* its properties, requirements, and the complete chain of super-class roles.
|
|
6
|
+
* For SVG namespace elements, also searches graphics ARIA roles.
|
|
7
|
+
*
|
|
8
|
+
* @param specs - The full markup language specification
|
|
9
|
+
* @param roleName - The name of the ARIA role to look up
|
|
10
|
+
* @param namespace - The namespace URI of the element context
|
|
11
|
+
* @param version - The ARIA specification version to use
|
|
12
|
+
* @returns The role specification with super-class roles, or null if the role does not exist
|
|
13
|
+
*/
|
|
3
14
|
export declare function getRoleSpec(specs: MLMLSpec, roleName: string, namespace: NamespaceURI, version: ARIAVersion): (ARIARole & {
|
|
4
15
|
superClassRoles: ARIARoleInSchema[];
|
|
5
16
|
}) | null;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { ariaSpecs } from './aria-specs.js';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the full ARIA role specification for a given role name, including
|
|
4
|
+
* its properties, requirements, and the complete chain of super-class roles.
|
|
5
|
+
* For SVG namespace elements, also searches graphics ARIA roles.
|
|
6
|
+
*
|
|
7
|
+
* @param specs - The full markup language specification
|
|
8
|
+
* @param roleName - The name of the ARIA role to look up
|
|
9
|
+
* @param namespace - The namespace URI of the element context
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @returns The role specification with super-class roles, or null if the role does not exist
|
|
12
|
+
*/
|
|
2
13
|
export function getRoleSpec(specs, roleName, namespace, version) {
|
|
3
14
|
const role = getRoleByName(specs, roleName, namespace, version);
|
|
4
15
|
if (!role) {
|
|
@@ -1,3 +1,26 @@
|
|
|
1
1
|
import type { ARIAVersion, ComputedRole, MLMLSpec } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether an element satisfies the "Required Owned Elements" constraint
|
|
4
|
+
* defined by its computed ARIA role. An element satisfies this constraint if it
|
|
5
|
+
* has `aria-owns`, or if any of its closest non-presentational descendants match
|
|
6
|
+
* the required owned element roles.
|
|
7
|
+
*
|
|
8
|
+
* @param el - The DOM element to check
|
|
9
|
+
* @param specs - The full markup language specification
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @returns `true` if the element has no required owned elements or the constraint is satisfied, `false` otherwise
|
|
12
|
+
*/
|
|
2
13
|
export declare function hasRequiredOwnedElement(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Determines whether an element with a given role matches a required owned element query.
|
|
16
|
+
* The query string may describe a single role or a parent-child relationship using `>` notation
|
|
17
|
+
* (e.g., `"listitem"` or `"group > listitem"`).
|
|
18
|
+
*
|
|
19
|
+
* @param el - The DOM element to test
|
|
20
|
+
* @param role - The computed role of the element
|
|
21
|
+
* @param query - The required owned element query string, optionally containing `>` for nested requirements
|
|
22
|
+
* @param specs - The full markup language specification
|
|
23
|
+
* @param version - The ARIA specification version to use
|
|
24
|
+
* @returns `true` if the element and its role match the required owned element query
|
|
25
|
+
*/
|
|
3
26
|
export declare function isRequiredOwnedElement(el: Element, role: ComputedRole['role'], query: string, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -2,6 +2,17 @@ import { isPresentational } from './is-presentational.js';
|
|
|
2
2
|
import { getComputedRole } from './get-computed-role.js';
|
|
3
3
|
import { getExplicitRole } from './get-explicit-role.js';
|
|
4
4
|
import { getImplicitRole } from './get-implicit-role.js';
|
|
5
|
+
/**
|
|
6
|
+
* Checks whether an element satisfies the "Required Owned Elements" constraint
|
|
7
|
+
* defined by its computed ARIA role. An element satisfies this constraint if it
|
|
8
|
+
* has `aria-owns`, or if any of its closest non-presentational descendants match
|
|
9
|
+
* the required owned element roles.
|
|
10
|
+
*
|
|
11
|
+
* @param el - The DOM element to check
|
|
12
|
+
* @param specs - The full markup language specification
|
|
13
|
+
* @param version - The ARIA specification version to use
|
|
14
|
+
* @returns `true` if the element has no required owned elements or the constraint is satisfied, `false` otherwise
|
|
15
|
+
*/
|
|
5
16
|
export function hasRequiredOwnedElement(
|
|
6
17
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
7
18
|
el, specs, version) {
|
|
@@ -30,6 +41,18 @@ el, specs, version) {
|
|
|
30
41
|
}
|
|
31
42
|
return false;
|
|
32
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Determines whether an element with a given role matches a required owned element query.
|
|
46
|
+
* The query string may describe a single role or a parent-child relationship using `>` notation
|
|
47
|
+
* (e.g., `"listitem"` or `"group > listitem"`).
|
|
48
|
+
*
|
|
49
|
+
* @param el - The DOM element to test
|
|
50
|
+
* @param role - The computed role of the element
|
|
51
|
+
* @param query - The required owned element query string, optionally containing `>` for nested requirements
|
|
52
|
+
* @param specs - The full markup language specification
|
|
53
|
+
* @param version - The ARIA specification version to use
|
|
54
|
+
* @returns `true` if the element and its role match the required owned element query
|
|
55
|
+
*/
|
|
33
56
|
export function isRequiredOwnedElement(
|
|
34
57
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
35
58
|
el, role, query, specs, version) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../../types/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Detects whether an element is included in (exposed to) the Accessibility Tree.
|
|
4
|
+
* Applies WAI-ARIA exclusion/inclusion rules, SVG rendering rules, and
|
|
5
|
+
* HTML metadata element filtering.
|
|
4
6
|
*
|
|
5
7
|
* @see https://www.w3.org/TR/wai-aria-1.2/#accessibility_tree
|
|
6
8
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param version
|
|
9
|
+
* @param el - The DOM element to check for accessibility tree exposure
|
|
10
|
+
* @param specs - The full markup language specification
|
|
11
|
+
* @param version - The ARIA specification version to use
|
|
12
|
+
* @returns `true` if the element should be exposed in the accessibility tree
|
|
10
13
|
*/
|
|
11
14
|
export declare function isExposed(el: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -4,13 +4,16 @@ import { isPresentational } from './is-presentational.js';
|
|
|
4
4
|
import { resolveNamespace } from '../../utils/resolve-namespace.js';
|
|
5
5
|
import { getComputedRole } from './get-computed-role.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Detects whether an element is included in (exposed to) the Accessibility Tree.
|
|
8
|
+
* Applies WAI-ARIA exclusion/inclusion rules, SVG rendering rules, and
|
|
9
|
+
* HTML metadata element filtering.
|
|
8
10
|
*
|
|
9
11
|
* @see https://www.w3.org/TR/wai-aria-1.2/#accessibility_tree
|
|
10
12
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param version
|
|
13
|
+
* @param el - The DOM element to check for accessibility tree exposure
|
|
14
|
+
* @param specs - The full markup language specification
|
|
15
|
+
* @param version - The ARIA specification version to use
|
|
16
|
+
* @returns `true` if the element should be exposed in the accessibility tree
|
|
14
17
|
*/
|
|
15
18
|
export function isExposed(
|
|
16
19
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a given role name corresponds to a presentational role
|
|
3
|
+
* (`"presentation"` or `"none"`), which indicates the element should be
|
|
4
|
+
* excluded from the accessibility tree.
|
|
5
|
+
*
|
|
6
|
+
* @param roleName - The ARIA role name to check, or undefined
|
|
7
|
+
* @returns `true` if the role name is `"presentation"` or `"none"`, `false` otherwise
|
|
8
|
+
*/
|
|
1
9
|
export declare function isPresentational(roleName?: string): boolean;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a given role name corresponds to a presentational role
|
|
3
|
+
* (`"presentation"` or `"none"`), which indicates the element should be
|
|
4
|
+
* excluded from the accessibility tree.
|
|
5
|
+
*
|
|
6
|
+
* @param roleName - The ARIA role name to check, or undefined
|
|
7
|
+
* @returns `true` if the role name is `"presentation"` or `"none"`, `false` otherwise
|
|
8
|
+
*/
|
|
1
9
|
export function isPresentational(roleName) {
|
|
2
10
|
if (!roleName) {
|
|
3
11
|
return false;
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import type { ARIAVersion, MLMLSpec } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether an element's parent hierarchy satisfies at least one of the
|
|
4
|
+
* required context role conditions. Each condition string may describe a chain
|
|
5
|
+
* of ancestor roles separated by ` > ` (e.g., `"list > group"`).
|
|
6
|
+
*
|
|
7
|
+
* @param conditions - An array of required context role condition strings to match against
|
|
8
|
+
* @param ownedEl - The owned DOM element whose parent context is being validated
|
|
9
|
+
* @param specs - The full markup language specification
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @returns `true` if any of the context role conditions are satisfied by the element's ancestors
|
|
12
|
+
*/
|
|
2
13
|
export declare function matchesContextRole(conditions: readonly string[], ownedEl: Element, specs: MLMLSpec, version: ARIAVersion): boolean;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { getComputedRole } from './get-computed-role.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether an element's parent hierarchy satisfies at least one of the
|
|
4
|
+
* required context role conditions. Each condition string may describe a chain
|
|
5
|
+
* of ancestor roles separated by ` > ` (e.g., `"list > group"`).
|
|
6
|
+
*
|
|
7
|
+
* @param conditions - An array of required context role condition strings to match against
|
|
8
|
+
* @param ownedEl - The owned DOM element whose parent context is being validated
|
|
9
|
+
* @param specs - The full markup language specification
|
|
10
|
+
* @param version - The ARIA specification version to use
|
|
11
|
+
* @returns `true` if any of the context role conditions are satisfied by the element's ancestors
|
|
12
|
+
*/
|
|
2
13
|
export function matchesContextRole(conditions,
|
|
3
14
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
15
|
ownedEl, specs, version) {
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../../types/index.js';
|
|
2
2
|
import type { Category } from '../../types/permitted-structures.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a content model category (e.g., `#flow`, `#phrasing`) to a sorted,
|
|
5
|
+
* frozen array of HTML/SVG tag names that belong to that category.
|
|
6
|
+
* Results are cached for repeated lookups.
|
|
7
|
+
*
|
|
8
|
+
* @param contentModel - The content model category identifier
|
|
9
|
+
* @param def - The specification definitions containing content model mappings
|
|
10
|
+
* @returns A frozen, sorted array of tag name strings belonging to the category
|
|
11
|
+
*/
|
|
3
12
|
export declare function contentModelCategoryToTagNames(contentModel: Category, def: MLMLSpec['def']): ReadonlyArray<string>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
const cache = new Map();
|
|
2
|
+
/**
|
|
3
|
+
* Converts a content model category (e.g., `#flow`, `#phrasing`) to a sorted,
|
|
4
|
+
* frozen array of HTML/SVG tag names that belong to that category.
|
|
5
|
+
* Results are cached for repeated lookups.
|
|
6
|
+
*
|
|
7
|
+
* @param contentModel - The content model category identifier
|
|
8
|
+
* @param def - The specification definitions containing content model mappings
|
|
9
|
+
* @returns A frozen, sorted array of tag name strings belonging to the category
|
|
10
|
+
*/
|
|
2
11
|
export function contentModelCategoryToTagNames(contentModel, def) {
|
|
3
12
|
const cached = cache.get(contentModel);
|
|
4
13
|
if (cached) {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ElementSpec } from '../../types/index.js';
|
|
2
2
|
type Specs = readonly Pick<ElementSpec, 'name' | 'contentModel'>[];
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the permitted content model for an element. Evaluates any conditional
|
|
5
|
+
* content models based on the element's current attributes (e.g., different content
|
|
6
|
+
* models for `<ol>` vs `<ol reversed>`). Results are cached per element and spec set.
|
|
7
|
+
*
|
|
8
|
+
* @param el - The DOM element to retrieve the content model for
|
|
9
|
+
* @param specs - The element specifications containing content model definitions
|
|
10
|
+
* @returns The permitted content patterns array, a boolean (true for any content, false for no content), or null if no spec exists
|
|
11
|
+
*/
|
|
3
12
|
export declare function getContentModel(el: Element, specs: Specs): boolean | readonly (import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../../types/permitted-structures.js").PermittedContentRequire> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../../types/permitted-structures.js").PermittedContentOptional> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../../types/permitted-structures.js").PermittedContentOneOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../../types/permitted-structures.js").PermittedContentZeroOrMore> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../../types/permitted-structures.js").PermittedContentChoice> | import("type-fest/source/readonly-deep.js").ReadonlyObjectDeep<import("../../types/permitted-structures.js").PermittedContentTransparent>)[] | null;
|
|
4
13
|
export {};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { getSpec } from '../../utils/get-spec.js';
|
|
2
2
|
const cachesBySpecs = new Map();
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the permitted content model for an element. Evaluates any conditional
|
|
5
|
+
* content models based on the element's current attributes (e.g., different content
|
|
6
|
+
* models for `<ol>` vs `<ol reversed>`). Results are cached per element and spec set.
|
|
7
|
+
*
|
|
8
|
+
* @param el - The DOM element to retrieve the content model for
|
|
9
|
+
* @param specs - The element specifications containing content model definitions
|
|
10
|
+
* @returns The permitted content patterns array, a boolean (true for any content, false for no content), or null if no spec exists
|
|
11
|
+
*/
|
|
3
12
|
export function getContentModel(
|
|
4
13
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
5
14
|
el, specs) {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../../types/index.js';
|
|
2
2
|
import type { Category } from '../../types/permitted-structures.js';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the CSS selectors associated with a content model category from the spec definitions.
|
|
5
|
+
* These selectors can be used to match elements that belong to the given category.
|
|
6
|
+
*
|
|
7
|
+
* @param specs - The full markup language specification
|
|
8
|
+
* @param category - The content model category identifier (e.g., `#flow`, `#interactive`)
|
|
9
|
+
* @returns A readonly array of CSS selector strings for the category, or an empty array if the category is not defined
|
|
10
|
+
*/
|
|
3
11
|
export declare function getSelectorsByContentModelCategory(specs: MLMLSpec, category: Category): ReadonlyArray<string>;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the CSS selectors associated with a content model category from the spec definitions.
|
|
3
|
+
* These selectors can be used to match elements that belong to the given category.
|
|
4
|
+
*
|
|
5
|
+
* @param specs - The full markup language specification
|
|
6
|
+
* @param category - The content model category identifier (e.g., `#flow`, `#interactive`)
|
|
7
|
+
* @returns A readonly array of CSS selector strings for the category, or an empty array if the category is not defined
|
|
8
|
+
*/
|
|
1
9
|
export function getSelectorsByContentModelCategory(specs, category) {
|
|
2
10
|
const selectors = specs.def['#contentModels'][category];
|
|
3
11
|
return selectors ?? [];
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Determines whether an element uses the "nothing" content model, meaning it
|
|
3
|
+
* must not contain any content. This includes void elements as well as
|
|
4
|
+
* `<iframe>` and `<template>` elements.
|
|
5
|
+
*
|
|
2
6
|
* @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
|
|
3
7
|
* @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
8
|
+
*
|
|
9
|
+
* @param el - The DOM element to check
|
|
10
|
+
* @returns `true` if the element has the "nothing" content model
|
|
4
11
|
*/
|
|
5
12
|
export declare function isNothingContentModel(el: Element): boolean;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { isVoidElement } from './is-void-element.js';
|
|
2
2
|
/**
|
|
3
|
+
* Determines whether an element uses the "nothing" content model, meaning it
|
|
4
|
+
* must not contain any content. This includes void elements as well as
|
|
5
|
+
* `<iframe>` and `<template>` elements.
|
|
6
|
+
*
|
|
3
7
|
* @see https://html.spec.whatwg.org/multipage/dom.html#the-nothing-content-model
|
|
4
8
|
* @see https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
|
9
|
+
*
|
|
10
|
+
* @param el - The DOM element to check
|
|
11
|
+
* @returns `true` if the element has the "nothing" content model
|
|
5
12
|
*/
|
|
6
13
|
export function isNothingContentModel(
|
|
7
14
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether an element is considered palpable content. Palpable elements
|
|
4
|
+
* are those that render something visible or meaningful to the user. Optionally
|
|
5
|
+
* extends the check to include SVG renderable elements and other exposable elements
|
|
6
|
+
* that do not belong to any standard content model category.
|
|
7
|
+
*
|
|
8
|
+
* @param el - The DOM element to check
|
|
9
|
+
* @param specs - The full markup language specification
|
|
10
|
+
* @param options - Optional flags to extend the palpable check
|
|
11
|
+
* @param options.extendsSvg - Whether to include SVG renderable elements (defaults to true)
|
|
12
|
+
* @param options.extendsExposableElements - Whether to include additional exposable elements like `<li>`, `<td>`, etc. (defaults to false)
|
|
13
|
+
* @returns `true` if the element is considered palpable content
|
|
14
|
+
*/
|
|
2
15
|
export declare function isPalpableElement(el: Element, specs: MLMLSpec, options?: {
|
|
3
16
|
readonly extendsSvg?: boolean;
|
|
4
17
|
readonly extendsExposableElements?: boolean;
|
|
@@ -28,6 +28,19 @@ const exposableElementsThatAreNoBelongingAModel = [
|
|
|
28
28
|
'thead',
|
|
29
29
|
'tr',
|
|
30
30
|
];
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether an element is considered palpable content. Palpable elements
|
|
33
|
+
* are those that render something visible or meaningful to the user. Optionally
|
|
34
|
+
* extends the check to include SVG renderable elements and other exposable elements
|
|
35
|
+
* that do not belong to any standard content model category.
|
|
36
|
+
*
|
|
37
|
+
* @param el - The DOM element to check
|
|
38
|
+
* @param specs - The full markup language specification
|
|
39
|
+
* @param options - Optional flags to extend the palpable check
|
|
40
|
+
* @param options.extendsSvg - Whether to include SVG renderable elements (defaults to true)
|
|
41
|
+
* @param options.extendsExposableElements - Whether to include additional exposable elements like `<li>`, `<td>`, etc. (defaults to false)
|
|
42
|
+
* @returns `true` if the element is considered palpable content
|
|
43
|
+
*/
|
|
31
44
|
export function isPalpableElement(
|
|
32
45
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
33
46
|
el, specs, options) {
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether an element is a void element as defined by the HTML specification.
|
|
3
|
+
* Void elements cannot have any contents (e.g., `<br>`, `<img>`, `<input>`).
|
|
4
|
+
*
|
|
5
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
6
|
+
*
|
|
7
|
+
* @param el - An object with a `localName` property representing the element's tag name
|
|
8
|
+
* @returns `true` if the element is a void element
|
|
9
|
+
*/
|
|
1
10
|
export declare function isVoidElement(el: {
|
|
2
11
|
readonly localName: string;
|
|
3
12
|
}): boolean;
|
|
@@ -16,6 +16,15 @@ const voidElements = new Set([
|
|
|
16
16
|
'track',
|
|
17
17
|
'wbr',
|
|
18
18
|
]);
|
|
19
|
+
/**
|
|
20
|
+
* Determines whether an element is a void element as defined by the HTML specification.
|
|
21
|
+
* Void elements cannot have any contents (e.g., `<br>`, `<img>`, `<input>`).
|
|
22
|
+
*
|
|
23
|
+
* @see https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
24
|
+
*
|
|
25
|
+
* @param el - An object with a `localName` property representing the element's tag name
|
|
26
|
+
* @returns `true` if the element is a void element
|
|
27
|
+
*/
|
|
19
28
|
export function isVoidElement(el) {
|
|
20
29
|
return voidElements.has(el.localName);
|
|
21
30
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { MLMLSpec } from '../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether an element may potentially be focusable, based on whether it matches
|
|
4
|
+
* interactive content selectors, has a `tabindex` attribute, or has a `contenteditable`
|
|
5
|
+
* attribute. This is a heuristic check that does not account for runtime state such as
|
|
6
|
+
* `disabled` or `inert` attributes.
|
|
7
|
+
*
|
|
8
|
+
* @param el - The DOM element to check
|
|
9
|
+
* @param specs - The full markup language specification containing interactive content definitions
|
|
10
|
+
* @returns `true` if the element may be focusable
|
|
11
|
+
*/
|
|
2
12
|
export declare function mayBeFocusable(el: Element, specs: MLMLSpec): boolean;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { getSelectorsByContentModelCategory } from './get-selectors-by-content-model-category.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether an element may potentially be focusable, based on whether it matches
|
|
4
|
+
* interactive content selectors, has a `tabindex` attribute, or has a `contenteditable`
|
|
5
|
+
* attribute. This is a heuristic check that does not account for runtime state such as
|
|
6
|
+
* `disabled` or `inert` attributes.
|
|
7
|
+
*
|
|
8
|
+
* @param el - The DOM element to check
|
|
9
|
+
* @param specs - The full markup language specification containing interactive content definitions
|
|
10
|
+
* @returns `true` if the element may be focusable
|
|
11
|
+
*/
|
|
2
12
|
export function mayBeFocusable(
|
|
3
13
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
4
14
|
el, specs) {
|