Implement PR feedback

Signed-off-by: Markus Hatvan <markus_hatvan@aon.at>
pull/5073/head
Markus Hatvan 5 years ago committed by tanhauhau
parent a04cc0f6df
commit 5ccd85e9ba

@ -578,10 +578,14 @@ export default class Element extends Node {
return; return;
} }
if (this.name === 'input') { const type_attribute = attribute_map.get('type');
const input_type = attribute_map.get('type');
if (input_type && input_type_interactive.has(input_type.get_static_value())) { if (this.name === 'input') {
if (
type_attribute &&
(!type_attribute.is_static ||
input_type_interactive.has(type_attribute.get_static_value()))
) {
return; return;
} }
} }
@ -592,14 +596,15 @@ export default class Element extends Node {
const aria_hidden_attribute = attribute_map.get('aria-hidden'); const aria_hidden_attribute = attribute_map.get('aria-hidden');
const aria_hidden_value = const aria_hidden_value =
aria_hidden_attribute && aria_hidden_attribute.get_static_value(); aria_hidden_attribute &&
(!aria_hidden_attribute.is_static ||
aria_hidden_attribute.get_static_value());
// aria-hidden value is string, check its boolean value with JSON.parse() // aria-hidden value is string, check its boolean value with JSON.parse()
if (aria_hidden_value && JSON.parse(aria_hidden_value)) { if (aria_hidden_value && JSON.parse(aria_hidden_value)) {
return; return;
} }
const type_attribute = attribute_map.get('type');
const type_value = type_attribute && type_attribute.get_static_value(); const type_value = type_attribute && type_attribute.get_static_value();
if (type_value && type_value === 'hidden') { if (type_value && type_value === 'hidden') {
@ -609,7 +614,9 @@ export default class Element extends Node {
const role_attribute = attribute_map.get('role'); const role_attribute = attribute_map.get('role');
const role_value = role_attribute && role_attribute.get_static_value(); const role_value = role_attribute && role_attribute.get_static_value();
const presentation_role_value = const presentation_role_value =
role_value === 'presentation' || role_value === 'none'; role_value === null ||
role_value === 'presentation' ||
role_value === 'none';
if (presentation_role_value) { if (presentation_role_value) {
return; return;

@ -2,12 +2,15 @@
function noop() {} function noop() {}
let props = {}; let props = {};
const dynamicTypeValue = "checkbox";
const dynamicAriaHiddenValue = "false";
const dynamicRole = "button";
</script> </script>
<!-- should warn --> <!-- should warn -->
<div on:click={noop} /> <div on:click={noop} />
<div on:click={noop} aria-hidden="false" /> <div on:click={noop} aria-hidden="false" />
<div on:click={noop} role={undefined} />
<section on:click={noop} /> <section on:click={noop} />
<main on:click={noop} /> <main on:click={noop} />
@ -25,6 +28,7 @@
<select on:click={noop} /> <select on:click={noop} />
<input type="button" on:click={noop} /> <input type="button" on:click={noop} />
<input type={dynamicTypeValue} on:click={noop} />
<div on:click={noop} {...props} /> <div on:click={noop} {...props} />
<div on:click={noop} on:keydown={noop} /> <div on:click={noop} on:keydown={noop} />
@ -40,6 +44,8 @@
<div on:click={noop} aria-hidden /> <div on:click={noop} aria-hidden />
<div on:click={noop} aria-hidden="true" /> <div on:click={noop} aria-hidden="true" />
<div on:click={noop} aria-hidden="false" on:keydown={noop} /> <div on:click={noop} aria-hidden="false" on:keydown={noop} />
<div on:click={noop} aria-hidden={dynamicAriaHiddenValue} />
<div on:click={noop} role="presentation" /> <div on:click={noop} role="presentation" />
<div on:click={noop} role="none" /> <div on:click={noop} role="none" />
<div on:click={noop} role={dynamicRole} />

@ -2,136 +2,121 @@
{ {
"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.",
"end": {
"character": 102,
"column": 23,
"line": 8
},
"start": { "start": {
"character": 79, "line": 12,
"column": 0, "column": 0,
"line": 8 "character": 190
}, },
"pos": 79 "end": {
"line": 12,
"column": 23,
"character": 213
},
"pos": 190
}, },
{ {
"code": "a11y-click-events-have-key-events", "code": "a11y-click-events-have-key-events",
"end": {
"character": 146,
"column": 43,
"line": 9
},
"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.",
"pos": 103,
"start": { "start": {
"character": 103, "line": 13,
"column": 0, "column": 0,
"line": 9 "character": 214
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 187, "line": 13,
"column": 40, "column": 43,
"line": 10 "character": 257
},
"pos": 214
}, },
{
"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.",
"pos": 147,
"start": { "start": {
"character": 147, "line": 15,
"column": 0, "column": 0,
"line": 10 "character": 259
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 216, "line": 15,
"column": 27, "column": 27,
"line": 12 "character": 286
},
"pos": 259
}, },
{
"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.",
"pos": 189,
"start": { "start": {
"character": 189, "line": 16,
"column": 0, "column": 0,
"line": 12 "character": 287
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 241, "line": 16,
"column": 24, "column": 24,
"line": 13 "character": 311
},
"pos": 287
}, },
{
"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.",
"pos": 217,
"start": { "start": {
"character": 217, "line": 17,
"column": 0, "column": 0,
"line": 13 "character": 312
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 269, "line": 17,
"column": 27, "column": 27,
"line": 14 "character": 339
}, },
"pos": 312
},
{
"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.",
"pos": 242,
"start": { "start": {
"character": 242, "line": 18,
"column": 0, "column": 0,
"line": 14 "character": 340
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 296, "line": 18,
"column": 26, "column": 26,
"line": 15 "character": 366
}, },
"pos": 340
},
{
"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.",
"pos": 270,
"start": { "start": {
"character": 270, "line": 19,
"column": 0, "column": 0,
"line": 15 "character": 367
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 323, "line": 19,
"column": 26, "column": 26,
"line": 16 "character": 393
},
"pos": 367
}, },
{
"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.",
"pos": 297,
"start": { "start": {
"character": 297, "line": 21,
"column": 0, "column": 0,
"line": 16 "character": 395
}
}, },
{
"code": "a11y-click-events-have-key-events",
"end": { "end": {
"character": 362, "line": 21,
"column": 37, "column": 37,
"line": 18 "character": 432
}, },
"message": "A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.", "pos": 395
"pos": 325,
"start": {
"character": 325,
"column": 0,
"line": 18
}
} }
] ]

Loading…
Cancel
Save