Fix things up after rebase

pull/8251/head
Tim McCabe 3 years ago
parent cae0fae65d
commit 22e0e0260d

@ -25,7 +25,7 @@ import { Literal } from 'estree';
import compiler_warnings from '../compiler_warnings'; import compiler_warnings from '../compiler_warnings';
import compiler_errors from '../compiler_errors'; import compiler_errors from '../compiler_errors';
import { ARIARoleDefinitionKey, roles, aria, ARIAPropertyDefinition, ARIAProperty } from 'aria-query'; import { ARIARoleDefinitionKey, roles, aria, ARIAPropertyDefinition, ARIAProperty } from 'aria-query';
import { is_non_interactive_element, is_interactive_element, is_non_interactive_roles, is_presentation_role, is_interactive_roles, is_hidden_from_screen_reader, is_semantic_role_element, is_abstract_role, is_static_element, has_disabled_attribute } from '../utils/a11y'; import { is_interactive_element, is_non_interactive_element, is_non_interactive_roles, is_presentation_role, is_interactive_roles, is_hidden_from_screen_reader, is_semantic_role_element, is_abstract_role, is_static_element, has_disabled_attribute } from '../utils/a11y';
const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' '); const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' ');
const aria_attribute_set = new Set(aria_attributes); const aria_attribute_set = new Set(aria_attributes);

@ -57,10 +57,7 @@ export function is_presentation_role(role: ARIARoleDefinitionKey) {
return presentation_roles.has(role); return presentation_roles.has(role);
} }
export function is_hidden_from_screen_reader( export function is_hidden_from_screen_reader(tag_name: string, attribute_map: Map<string, Attribute>) {
tag_name: string,
attribute_map: Map<string, Attribute>
) {
if (tag_name === 'input') { if (tag_name === 'input') {
const type = attribute_map.get('type')?.get_static_value(); const type = attribute_map.get('type')?.get_static_value();
@ -212,21 +209,11 @@ export function is_static_element(tag_name: string, attribute_map: Map<string, A
return element_interactivity(tag_name, attribute_map) === ElementInteractivity.Static; return element_interactivity(tag_name, attribute_map) === ElementInteractivity.Static;
} }
export function is_semantic_role_element( export function is_semantic_role_element(role: ARIARoleDefinitionKey, tag_name: string, attribute_map: Map<string, Attribute>) {
role: ARIARoleDefinitionKey,
tag_name: string,
attribute_map: Map<string, Attribute>
) {
for (const [schema, ax_object] of elementAXObjects.entries()) { for (const [schema, ax_object] of elementAXObjects.entries()) {
if ( if (schema.name === tag_name && (!schema.attributes || schema.attributes.every(
schema.name === tag_name && (attr) => attribute_map.has(attr.name) && attribute_map.get(attr.name).get_static_value() === attr.value
(!schema.attributes || ))) {
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) { for (const name of ax_object) {
const roles = AXObjectRoles.get(name); const roles = AXObjectRoles.get(name);
if (roles) { if (roles) {

@ -64,4 +64,5 @@
<div on:click={noop} role="none" /> <div on:click={noop} role="none" />
<div on:click={noop} role={dynamicRole} /> <div on:click={noop} role={dynamicRole} />
<!-- svelte-ignore a11y-no-static-element-interactions -->
<svelte:element this={Math.random() ? 'button' : 'div'} on:click={noop} /> <svelte:element this={Math.random() ? 'button' : 'div'} on:click={noop} />

@ -3,86 +3,47 @@
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
<<<<<<< HEAD "line": 13,
"line": 12,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 12, "line": 13,
"column": 23 "column": 23
} }
=======
"line": 13,
"column": 0,
"character": 249
},
"end": {
"line": 13,
"column": 23,
"character": 272
},
"pos": 249
>>>>>>> 752aa35ed (add no-static-element-interactions compiler rule)
}, },
{ {
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
<<<<<<< HEAD "line": 15,
"line": 13,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 13, "line": 15,
"column": 43 "column": 43
} }
=======
"line": 15,
"column": 0,
"character": 332
},
"end": {
"line": 15,
"column": 43,
"character": 375
},
"pos": 332
>>>>>>> 752aa35ed (add no-static-element-interactions compiler rule)
}, },
{ {
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
<<<<<<< HEAD "line": 18,
"line": 15,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 15, "line": 18,
"column": 27 "column": 27
} }
=======
"line": 18,
"column": 0,
"character": 436
},
"end": {
"line": 18,
"column": 27,
"character": 463
},
"pos": 436
>>>>>>> 752aa35ed (add no-static-element-interactions compiler rule)
}, },
{ {
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
"line": 16, "line": 19,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 16, "line": 19,
"column": 24 "column": 24
} }
}, },
@ -90,11 +51,11 @@
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
"line": 17, "line": 20,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 17, "line": 20,
"column": 27 "column": 27
} }
}, },
@ -102,50 +63,24 @@
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
<<<<<<< HEAD "line": 22,
"line": 18,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 18, "line": 22,
"column": 26 "column": 26
} }
=======
"line": 22,
"column": 0,
"character": 576
},
"end": {
"line": 22,
"column": 26,
"character": 602
},
"pos": 576
>>>>>>> 752aa35ed (add no-static-element-interactions compiler rule)
}, },
{ {
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.",
"start": { "start": {
<<<<<<< HEAD "line": 23,
"line": 19,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 19, "line": 23,
"column": 26 "column": 26
} }
=======
"line": 23,
"column": 0,
"character": 603
},
"end": {
"line": 23,
"column": 26,
"character": 629
},
"pos": 603
>>>>>>> 752aa35ed (add no-static-element-interactions compiler rule)
} }
] ]

@ -1,50 +1,50 @@
[ [
{ {
"code": "a11y-mouse-events-have-key-events", "code": "a11y-mouse-events-have-key-events",
"end": { "end": {
"column": 35, "column": 35,
"line": 10 "line": 11
}, },
"message": "A11y: on:mouseover must be accompanied by on:focus", "message": "A11y: on:mouseover must be accompanied by on:focus",
"start": { "start": {
"column": 0, "column": 0,
"line": 10 "line": 11
} }
}, },
{ {
"code": "a11y-mouse-events-have-key-events", "code": "a11y-mouse-events-have-key-events",
"end": { "end": {
"column": 51, "column": 51,
"line": 12 "line": 15
}, },
"message": "A11y: on:mouseover must be accompanied by on:focus", "message": "A11y: on:mouseover must be accompanied by on:focus",
"start": { "start": {
"column": 0, "column": 0,
"line": 12 "line": 15
} }
}, },
{ {
"code": "a11y-mouse-events-have-key-events", "code": "a11y-mouse-events-have-key-events",
"end": { "end": {
"column": 34, "column": 34,
"line": 13 "line": 17
}, },
"message": "A11y: on:mouseout must be accompanied by on:blur", "message": "A11y: on:mouseout must be accompanied by on:blur",
"start": { "start": {
"column": 0, "column": 0,
"line": 13 "line": 17
} }
}, },
{ {
"code": "a11y-mouse-events-have-key-events", "code": "a11y-mouse-events-have-key-events",
"end": { "end": {
"column": 50, "column": 50,
"line": 15 "line": 21
}, },
"message": "A11y: on:mouseout must be accompanied by on:blur", "message": "A11y: on:mouseout must be accompanied by on:blur",
"start": { "start": {
"column": 0, "column": 0,
"line": 15 "line": 21
} }
} }
] ]

@ -4,6 +4,7 @@
<!-- valid --> <!-- valid -->
<button on:click={() => {}} /> <button on:click={() => {}} />
<!-- svelte-ignore a11y-interactive-supports-focus -->
<div on:keydown={() => {}} role="button" /> <div on:keydown={() => {}} role="button" />
<input type="text" on:click={() => {}} /> <input type="text" on:click={() => {}} />
<div on:copy={() => {}} /> <div on:copy={() => {}} />

@ -2,31 +2,25 @@
{ {
"code": "a11y-no-static-element-interactions", "code": "a11y-no-static-element-interactions",
"end": { "end": {
"character": 381,
"column": 29, "column": 29,
"line": 15 "line": 16
}, },
"message": "A11y: <div> with keydown handler must have an ARIA role", "message": "A11y: <div> with keydown handler must have an ARIA role",
"pos": 352,
"start": { "start": {
"character": 352,
"column": 0, "column": 0,
"line": 15 "line": 16
} }
}, },
{ {
"code": "a11y-no-static-element-interactions", "code": "a11y-no-static-element-interactions",
"end": { "end": {
"character": 504,
"column": 76, "column": 76,
"line": 17 "line": 18
}, },
"message": "A11y: <a> with mousedown, mouseup handlers must have an ARIA role", "message": "A11y: <a> with mousedown, mouseup handlers must have an ARIA role",
"pos": 428,
"start": { "start": {
"character": 428,
"column": 0, "column": 0,
"line": 17 "line": 18
} }
} }
] ]

@ -8,7 +8,7 @@
}, },
"end": { "end": {
"column": 35, "column": 35,
"line": 6 "line": 7
} }
} }
] ]

@ -8,7 +8,7 @@
}, },
"end": { "end": {
"column": 35, "column": 35,
"line": 7 "line": 8
} }
} }
] ]

Loading…
Cancel
Save