Skip to content

Commit 2234df7

Browse files
committedJun 21, 2020
Account for additional control elements in label-has-associated-control
1 parent 1614b85 commit 2234df7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

Diff for: ‎__tests__/src/rules/label-has-associated-control-test.js

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ const nestingValid = [
4848
{ code: '<label><span><span><span><span>A label</span><input /></span></span></span></label>', options: [{ depth: 5 }] },
4949
{ code: '<label><span><span><span><span aria-label="A label" /><input /></span></span></span></label>', options: [{ depth: 5 }] },
5050
{ code: '<label><span><span><span><input aria-label="A label" /></span></span></span></label>', options: [{ depth: 5 }] },
51+
// Other controls
52+
{ code: '<label>foo<meter /></label>' },
53+
{ code: '<label>foo<output /></label>' },
54+
{ code: '<label>foo<progress /></label>' },
55+
{ code: '<label>foo<textarea /></label>' },
5156
// Custom controlComponents.
5257
{ code: '<label><span>A label<CustomInput /></span></label>', options: [{ controlComponents: ['CustomInput'] }] },
5358
{ code: '<CustomLabel><span>A label<CustomInput /></span></CustomLabel>', options: [{ controlComponents: ['CustomInput'], labelComponents: ['CustomLabel'] }] },

Diff for: ‎src/rules/label-has-associated-control.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ module.exports = {
5757
if (componentNames.indexOf(elementType(node.openingElement)) === -1) {
5858
return;
5959
}
60-
const controlComponents = ['input', 'select', 'textarea'].concat((options.controlComponents || []));
60+
const controlComponents = [
61+
'input',
62+
'meter',
63+
'output',
64+
'progress',
65+
'select',
66+
'textarea',
67+
].concat((options.controlComponents || []));
6168
// Prevent crazy recursion.
6269
const recursionDepth = Math.min(
6370
options.depth === undefined ? 2 : options.depth,

0 commit comments

Comments
 (0)
Please sign in to comment.