Skip to content

Commit 6c33bcb

Browse files
committed
Add select to the list of default control elements in label-has-associated-control
1 parent c0ca0b8 commit 6c33bcb

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

__tests__/src/rules/label-has-associated-control-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const bothValid = [
6363
{ code: '<CustomLabel htmlFor="js_id" label="A label"><input /></CustomLabel>', options: [{ labelAttributes: ['label'], labelComponents: ['CustomLabel'] }] },
6464
// Custom label attributes.
6565
{ code: '<label htmlFor="js_id" label="A label"><input /></label>', options: [{ labelAttributes: ['label'] }] },
66+
{ code: '<label htmlFor="selectInput">Some text<select id="selectInput" /></label>' },
6667
];
6768

6869
const alwaysValid = [

src/rules/label-has-associated-control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module.exports = {
5757
if (componentNames.indexOf(elementType(node.openingElement)) === -1) {
5858
return;
5959
}
60-
const controlComponents = ['input', 'textarea'].concat((options.controlComponents || []));
60+
const controlComponents = ['input', 'select', 'textarea'].concat((options.controlComponents || []));
6161
// Prevent crazy recursion.
6262
const recursionDepth = Math.min(
6363
options.depth === undefined ? 2 : options.depth,

0 commit comments

Comments
 (0)