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;
}
if (this.name === 'input') {
const input_type = attribute_map.get('type');
const type_attribute = 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;
}
}
@ -592,14 +596,15 @@ export default class Element extends Node {
const aria_hidden_attribute = attribute_map.get('aria-hidden');
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()
if (aria_hidden_value && JSON.parse(aria_hidden_value)) {
return;
}
const type_attribute = attribute_map.get('type');
const type_value = type_attribute && type_attribute.get_static_value();
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_value = role_attribute && role_attribute.get_static_value();
const presentation_role_value =
role_value === 'presentation' || role_value === 'none';
role_value === null ||
role_value === 'presentation' ||
role_value === 'none';
if (presentation_role_value) {
return;

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

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

Loading…
Cancel
Save