@@ -19,6 +19,12 @@ ruleTester.run('template-require-input-label', rule, {
1919 '<template><input id="probablyHasLabel" /></template>' ,
2020 '<template><input aria-label={{labelText}} /></template>' ,
2121 '<template><input aria-labelledby="someIdValue" /></template>' ,
22+ // https://github.com/ember-template-lint/ember-template-lint/issues/3388
23+ // id alone does not establish a labeling relationship — a <label for> is
24+ // needed and cannot be verified statically. Only aria-label/labelledby
25+ // should count.
26+ '<template><input id="hello" aria-label="hello" /></template>' ,
27+ '<template><input id="hello" aria-labelledby="someIdValue" /></template>' ,
2228 '<template><div></div></template>' ,
2329 '<template><Input id="foo" /></template>' ,
2430 '<template>{{input id="foo"}}</template>' ,
@@ -97,12 +103,14 @@ ruleTester.run('template-require-input-label', rule, {
97103 errors : [ { message : MULTIPLE_LABELS } ] ,
98104 } ,
99105 {
100- code : '<template><input id=" label- input" aria-label="second label"></template>' ,
106+ code : '<template><label>Input label< input aria-label="Custom label"></label ></template>' ,
101107 output : null ,
102108 errors : [ { message : MULTIPLE_LABELS } ] ,
103109 } ,
104110 {
105- code : '<template><label>Input label<input aria-label="Custom label"></label></template>' ,
111+ // id is irrelevant for labelling here — wrapping <label> + aria-label is
112+ // still multiple labels.
113+ code : '<template><label>Input label<input id="foo" aria-label="Custom label"></label></template>' ,
106114 output : null ,
107115 errors : [ { message : MULTIPLE_LABELS } ] ,
108116 } ,
@@ -173,6 +181,9 @@ hbsRuleTester.run('template-require-input-label', rule, {
173181 '<input id="probablyHasLabel" />' ,
174182 '<input aria-label={{labelText}} />' ,
175183 '<input aria-labelledby="someIdValue" />' ,
184+ // https://github.com/ember-template-lint/ember-template-lint/issues/3388
185+ '<input id="hello" aria-label="hello" />' ,
186+ '<input id="hello" aria-labelledby="someIdValue" />' ,
176187 '<div></div>' ,
177188 '<Input id="foo" />' ,
178189 '{{input id="foo"}}' ,
@@ -261,12 +272,12 @@ hbsRuleTester.run('template-require-input-label', rule, {
261272 errors : [ { message : MULTIPLE_LABELS } ] ,
262273 } ,
263274 {
264- code : '<input id=" label- input" aria-label="second label">' ,
275+ code : '<label>Input label< input aria-label="Custom label"></label >' ,
265276 output : null ,
266277 errors : [ { message : MULTIPLE_LABELS } ] ,
267278 } ,
268279 {
269- code : '<label>Input label<input aria-label="Custom label"></label>' ,
280+ code : '<label>Input label<input id="foo" aria-label="Custom label"></label>' ,
270281 output : null ,
271282 errors : [ { message : MULTIPLE_LABELS } ] ,
272283 } ,
0 commit comments