Skip to content

Commit 84007a8

Browse files
Merge pull request #92 from htmlacademy/fix/input-req-label
Fix input-req-label
2 parents 55d716a + 0db4aa6 commit 84007a8

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

rules/input-req-label/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@
3939

4040
<input type="hidden" value="dinosaur">
4141

42+
<input type="submit" value="submit">
4243
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- without a value for the value attribute -->
2+
<input type="submit" value="">
3+
4+
<!-- without the value attribute -->
5+
<input type="submit">
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- [type="submit"] with the specified value in the value attribute -->
2+
<input type="submit" value="Отправить">

rules/input-req-label/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = {
2828
if (!is_tag_node(node) || !['input', 'label'].includes(node.name)) {
2929
return;
3030
}
31+
3132
// if it's a label with a 'for', store that value
3233
if (node.name === 'label') {
3334
const for_attribute = attribute_value(node, 'for');
@@ -37,11 +38,10 @@ module.exports = {
3738
return;
3839
}
3940

40-
if (attribute_has_value(node, 'type', 'hidden')) {
41-
return;
42-
}
41+
const isHiddenOrSubmitType = (input) => ['hidden', 'submit'].some((type) => attribute_has_value(input, 'type', type));
42+
const hasAriaLabel = has_non_empty_attribute(node, 'aria-label');
4343

44-
if (has_non_empty_attribute(node, 'aria-label')) {
44+
if (isHiddenOrSubmitType(node) || hasAriaLabel) {
4545
return;
4646
}
4747

0 commit comments

Comments
 (0)