mirror of https://github.com/sveltejs/svelte
parent
34e831b88d
commit
4b67ea9562
@ -0,0 +1,46 @@
|
||||
import { AXObjectRoles, elementAXObjects } from 'axobject-query';
|
||||
import Attribute from '../../nodes/Attribute';
|
||||
|
||||
export default (
|
||||
name: string,
|
||||
attribute_map: Map<string, Attribute>
|
||||
): boolean => {
|
||||
if (!attribute_map.has('role')) {
|
||||
return false;
|
||||
}
|
||||
const value = attribute_map.get('role').get_static_value();
|
||||
|
||||
for (const [concept, ax_objects] of elementAXObjects) {
|
||||
if (
|
||||
// @ts-ignore
|
||||
concept.name === name &&
|
||||
// @ts-ignore
|
||||
(concept.attributes
|
||||
? // @ts-ignore
|
||||
concept.attributes.every(
|
||||
attribute =>
|
||||
attribute_map.has(attribute.name) &&
|
||||
(attribute.value !== undefined
|
||||
? (console.log(
|
||||
attribute_map.get(attribute.name).get_static_value(),
|
||||
attribute.value
|
||||
),
|
||||
attribute_map.get(attribute.name).get_static_value()) ===
|
||||
attribute.value
|
||||
: true)
|
||||
)
|
||||
: true)
|
||||
) {
|
||||
for (const ax_object of ax_objects) {
|
||||
if (AXObjectRoles.has(ax_object)) {
|
||||
for (const role of AXObjectRoles.get(ax_object)) {
|
||||
if (role.name === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
@ -0,0 +1,43 @@
|
||||
<!-- valid -->
|
||||
<Bar baz />
|
||||
<MyComponent role="combobox" />
|
||||
<div />
|
||||
<div></div>
|
||||
<div role={role} />
|
||||
<div role={role || "button"} />
|
||||
<div role={role || "foobar"} />
|
||||
<div role="row" />
|
||||
<span role="checkbox" aria-checked="false" aria-labelledby="foo" tabindex="0"></span>
|
||||
<input type="checkbox" role="switch" />
|
||||
<!-- invalid -->
|
||||
<!-- slider -->
|
||||
<div role="slider" />
|
||||
<div role="slider" aria-valuemax={1} />
|
||||
<div role="slider" aria-valuemax={1} aria-valuemin={1} />
|
||||
<div role="slider" aria-valuemax={1} aria-valuenow={1} />
|
||||
<div role="slider" aria-valuemin={1} aria-valuenow={1} />
|
||||
<!-- spinbutton -->
|
||||
<div role="spinbutton" />
|
||||
<div role="spinbutton" aria-valuemax={1} />
|
||||
<div role="spinbutton" aria-valuemax={1} aria-valuemin={1} />
|
||||
<div role="spinbutton" aria-valuemax={1} aria-valuenow={1} />
|
||||
<div role="spinbutton" aria-valuemin={1} aria-valuenow={1} />
|
||||
<!-- checkbox -->
|
||||
<div role="checkbox" />
|
||||
<div role="checkbox" checked />
|
||||
<div role="checkbox" aria-chcked />
|
||||
<span role="checkbox" aria-labelledby="foo" tabindex="0"></span>
|
||||
<!-- combobox -->
|
||||
<div role="combobox" />
|
||||
<div role="combobox" expanded />
|
||||
<div role="combobox" aria-expandd />
|
||||
<!-- scrollbar -->
|
||||
<div role="scrollbar" />
|
||||
<div role="scrollbar" aria-valuemax={1} />
|
||||
<div role="scrollbar" aria-valuemax={1} aria-valuemin={1} />
|
||||
<div role="scrollbar" aria-valuemax={1} aria-valuenow={1} />
|
||||
<div role="scrollbar" aria-valuemin={1} aria-valuenow={1} />
|
||||
|
||||
<script>
|
||||
let Bar, MyComponent, role, props;
|
||||
</script>
|
@ -0,0 +1,362 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 359,
|
||||
"column": 18,
|
||||
"line": 14
|
||||
},
|
||||
"message": "Elements with the ARIA role \"slider\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 346,
|
||||
"start": {
|
||||
"character": 346,
|
||||
"column": 5,
|
||||
"line": 14
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 381,
|
||||
"column": 18,
|
||||
"line": 15
|
||||
},
|
||||
"message": "Elements with the ARIA role \"slider\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 368,
|
||||
"start": {
|
||||
"character": 368,
|
||||
"column": 5,
|
||||
"line": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 421,
|
||||
"column": 18,
|
||||
"line": 16
|
||||
},
|
||||
"message": "Elements with the ARIA role \"slider\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 408,
|
||||
"start": {
|
||||
"character": 408,
|
||||
"column": 5,
|
||||
"line": 16
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 479,
|
||||
"column": 18,
|
||||
"line": 17
|
||||
},
|
||||
"message": "Elements with the ARIA role \"slider\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 466,
|
||||
"start": {
|
||||
"character": 466,
|
||||
"column": 5,
|
||||
"line": 17
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 537,
|
||||
"column": 18,
|
||||
"line": 18
|
||||
},
|
||||
"message": "Elements with the ARIA role \"slider\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 524,
|
||||
"start": {
|
||||
"character": 524,
|
||||
"column": 5,
|
||||
"line": 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 619,
|
||||
"column": 22,
|
||||
"line": 20
|
||||
},
|
||||
"message": "Elements with the ARIA role \"spinbutton\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 602,
|
||||
"start": {
|
||||
"character": 602,
|
||||
"column": 5,
|
||||
"line": 20
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 645,
|
||||
"column": 22,
|
||||
"line": 21
|
||||
},
|
||||
"message": "Elements with the ARIA role \"spinbutton\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 628,
|
||||
"start": {
|
||||
"character": 628,
|
||||
"column": 5,
|
||||
"line": 21
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 689,
|
||||
"column": 22,
|
||||
"line": 22
|
||||
},
|
||||
"message": "Elements with the ARIA role \"spinbutton\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 672,
|
||||
"start": {
|
||||
"character": 672,
|
||||
"column": 5,
|
||||
"line": 22
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 751,
|
||||
"column": 22,
|
||||
"line": 23
|
||||
},
|
||||
"message": "Elements with the ARIA role \"spinbutton\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 734,
|
||||
"start": {
|
||||
"character": 734,
|
||||
"column": 5,
|
||||
"line": 23
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 813,
|
||||
"column": 22,
|
||||
"line": 24
|
||||
},
|
||||
"message": "Elements with the ARIA role \"spinbutton\" must have the following attributes defined: aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 796,
|
||||
"start": {
|
||||
"character": 796,
|
||||
"column": 5,
|
||||
"line": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 891,
|
||||
"column": 20,
|
||||
"line": 26
|
||||
},
|
||||
"message": "Elements with the ARIA role \"checkbox\" must have the following attributes defined: aria-checked.",
|
||||
"pos": 876,
|
||||
"start": {
|
||||
"character": 876,
|
||||
"column": 5,
|
||||
"line": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 915,
|
||||
"column": 20,
|
||||
"line": 27
|
||||
},
|
||||
"message": "Elements with the ARIA role \"checkbox\" must have the following attributes defined: aria-checked.",
|
||||
"pos": 900,
|
||||
"start": {
|
||||
"character": 900,
|
||||
"column": 5,
|
||||
"line": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-unknown-aria-attribute",
|
||||
"end": {
|
||||
"character": 959,
|
||||
"column": 32,
|
||||
"line": 28
|
||||
},
|
||||
"message": "A11y: Unknown aria attribute 'aria-chcked' (did you mean 'aria-checked'?)",
|
||||
"pos": 948,
|
||||
"start": {
|
||||
"character": 948,
|
||||
"column": 21,
|
||||
"line": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 947,
|
||||
"column": 20,
|
||||
"line": 28
|
||||
},
|
||||
"message": "Elements with the ARIA role \"checkbox\" must have the following attributes defined: aria-checked.",
|
||||
"pos": 932,
|
||||
"start": {
|
||||
"character": 932,
|
||||
"column": 5,
|
||||
"line": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 984,
|
||||
"column": 21,
|
||||
"line": 29
|
||||
},
|
||||
"message": "Elements with the ARIA role \"checkbox\" must have the following attributes defined: aria-checked.",
|
||||
"pos": 969,
|
||||
"start": {
|
||||
"character": 969,
|
||||
"column": 6,
|
||||
"line": 29
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1066,
|
||||
"column": 20,
|
||||
"line": 31
|
||||
},
|
||||
"message": "Elements with the ARIA role \"combobox\" must have the following attributes defined: aria-controls,aria-expanded.",
|
||||
"pos": 1051,
|
||||
"start": {
|
||||
"character": 1051,
|
||||
"column": 5,
|
||||
"line": 31
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1090,
|
||||
"column": 20,
|
||||
"line": 32
|
||||
},
|
||||
"message": "Elements with the ARIA role \"combobox\" must have the following attributes defined: aria-controls,aria-expanded.",
|
||||
"pos": 1075,
|
||||
"start": {
|
||||
"character": 1075,
|
||||
"column": 5,
|
||||
"line": 32
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-unknown-aria-attribute",
|
||||
"end": {
|
||||
"character": 1136,
|
||||
"column": 33,
|
||||
"line": 33
|
||||
},
|
||||
"message": "A11y: Unknown aria attribute 'aria-expandd' (did you mean 'aria-expanded'?)",
|
||||
"pos": 1124,
|
||||
"start": {
|
||||
"character": 1124,
|
||||
"column": 21,
|
||||
"line": 33
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1123,
|
||||
"column": 20,
|
||||
"line": 33
|
||||
},
|
||||
"message": "Elements with the ARIA role \"combobox\" must have the following attributes defined: aria-controls,aria-expanded.",
|
||||
"pos": 1108,
|
||||
"start": {
|
||||
"character": 1108,
|
||||
"column": 5,
|
||||
"line": 33
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1180,
|
||||
"column": 21,
|
||||
"line": 35
|
||||
},
|
||||
"message": "Elements with the ARIA role \"scrollbar\" must have the following attributes defined: aria-controls,aria-orientation,aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 1164,
|
||||
"start": {
|
||||
"character": 1164,
|
||||
"column": 5,
|
||||
"line": 35
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1205,
|
||||
"column": 21,
|
||||
"line": 36
|
||||
},
|
||||
"message": "Elements with the ARIA role \"scrollbar\" must have the following attributes defined: aria-controls,aria-orientation,aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 1189,
|
||||
"start": {
|
||||
"character": 1189,
|
||||
"column": 5,
|
||||
"line": 36
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1248,
|
||||
"column": 21,
|
||||
"line": 37
|
||||
},
|
||||
"message": "Elements with the ARIA role \"scrollbar\" must have the following attributes defined: aria-controls,aria-orientation,aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 1232,
|
||||
"start": {
|
||||
"character": 1232,
|
||||
"column": 5,
|
||||
"line": 37
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1309,
|
||||
"column": 21,
|
||||
"line": 38
|
||||
},
|
||||
"message": "Elements with the ARIA role \"scrollbar\" must have the following attributes defined: aria-controls,aria-orientation,aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 1293,
|
||||
"start": {
|
||||
"character": 1293,
|
||||
"column": 5,
|
||||
"line": 38
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-has-required-aria-props",
|
||||
"end": {
|
||||
"character": 1370,
|
||||
"column": 21,
|
||||
"line": 39
|
||||
},
|
||||
"message": "Elements with the ARIA role \"scrollbar\" must have the following attributes defined: aria-controls,aria-orientation,aria-valuemax,aria-valuemin,aria-valuenow.",
|
||||
"pos": 1354,
|
||||
"start": {
|
||||
"character": 1354,
|
||||
"column": 5,
|
||||
"line": 39
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,5 @@
|
||||
<a href="foo.bar" aria-checked>anchor</a>
|
||||
<link href="#" aria-checked />
|
||||
<img alt="foobar" aria-checked />
|
||||
<menu type="toolbar" aria-checked />
|
||||
<aside aria-checked />
|
@ -0,0 +1,77 @@
|
||||
[
|
||||
{
|
||||
"code": "a11y-role-supports-aria-props",
|
||||
"end": {
|
||||
"character": 30,
|
||||
"column": 30,
|
||||
"line": 1
|
||||
},
|
||||
"message": "The attribute aria-checked is not supported by the role \"link\".\nThis role is implicit on the element \"a\".",
|
||||
"pos": 18,
|
||||
"start": {
|
||||
"character": 18,
|
||||
"column": 18,
|
||||
"line": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-supports-aria-props",
|
||||
"end": {
|
||||
"character": 69,
|
||||
"column": 27,
|
||||
"line": 2
|
||||
},
|
||||
"message": "The attribute aria-checked is not supported by the role \"link\".\nThis role is implicit on the element \"link\".",
|
||||
"pos": 57,
|
||||
"start": {
|
||||
"character": 57,
|
||||
"column": 15,
|
||||
"line": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-supports-aria-props",
|
||||
"end": {
|
||||
"character": 103,
|
||||
"column": 30,
|
||||
"line": 3
|
||||
},
|
||||
"message": "The attribute aria-checked is not supported by the role \"img\".\nThis role is implicit on the element \"img\".",
|
||||
"pos": 91,
|
||||
"start": {
|
||||
"character": 91,
|
||||
"column": 18,
|
||||
"line": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-supports-aria-props",
|
||||
"end": {
|
||||
"character": 140,
|
||||
"column": 33,
|
||||
"line": 4
|
||||
},
|
||||
"message": "The attribute aria-checked is not supported by the role \"toolbar\".\nThis role is implicit on the element \"menu\".",
|
||||
"pos": 128,
|
||||
"start": {
|
||||
"character": 128,
|
||||
"column": 21,
|
||||
"line": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "a11y-role-supports-aria-props",
|
||||
"end": {
|
||||
"character": 163,
|
||||
"column": 19,
|
||||
"line": 5
|
||||
},
|
||||
"message": "The attribute aria-checked is not supported by the role \"complementary\".\nThis role is implicit on the element \"aside\".",
|
||||
"pos": 151,
|
||||
"start": {
|
||||
"character": 151,
|
||||
"column": 7,
|
||||
"line": 5
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in new issue