Skip to content

Commit d72d360

Browse files
authored
Merge branch 'master' into update-aria-query
2 parents 2706495 + c1f763a commit d72d360

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

__tests__/src/rules/label-has-for-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,15 @@ ruleTester.run('label-has-for', rule, {
165165
{ code: '<label>First Name</label>', errors: [expectedSomeError], options: optionsRequiredSome },
166166
{ code: '<label>{children}</label>', errors: [expectedSomeError], options: optionsRequiredSome },
167167
{ code: '<label>{children}</label>', errors: [expectedNestingError], options: optionsRequiredNesting },
168+
{
169+
code: '<form><input type="text" id="howmuch" value="1" /><label htmlFor="howmuch">How much ?</label></form>',
170+
errors: [expectedEveryError],
171+
options: optionsRequiredEvery,
172+
},
173+
{
174+
code: '<form><input type="text" id="howmuch" value="1" /><label htmlFor="howmuch">How much ?<span /></label></form>',
175+
errors: [expectedEveryError],
176+
options: optionsRequiredEvery,
177+
},
168178
].map(parserOptionsMapper),
169179
});

__tests__/src/util/hasAccessibleChild-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ describe('hasAccessibleChild', () => {
3636
expect(hasAccessibleChild(element)).toBe(true);
3737
});
3838

39+
it('Returns true for JSXText Element', () => {
40+
const child = {
41+
type: 'JSXText',
42+
value: 'foo',
43+
};
44+
const element = JSXElementMock('div', [], [child]);
45+
expect(hasAccessibleChild(element)).toBe(true);
46+
});
47+
3948
it('Returns false for hidden child JSXElement', () => {
4049
const ariaHiddenAttr = JSXAttributeMock('aria-hidden', true);
4150
const child = JSXElementMock('div', [ariaHiddenAttr]);

docs/rules/no-noninteractive-element-interactions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ This preserves the table cell semantics and the button semantics; the two are no
7777

7878
#### Option 2, convert the table into an ARIA grid
7979

80-
If you're user interface has a table-like layout, but is filled with interactive components in the cells, consider converting the table into a grid.
80+
If your user interface has a table-like layout, but is filled with interactive components in the cells, consider converting the table into a grid.
8181

8282
```
8383
<table role="grid">

src/rules/label-has-for.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const schema = {
2727
},
2828
};
2929

30-
const validateNesting = node => node.parent.children.some(child => child.type === 'JSXElement');
30+
const validateNesting = node => node.parent.children.some((child) => {
31+
const opener = child.openingElement;
32+
return child.type === 'JSXElement' && opener && opener.name.name === 'input';
33+
});
3134

3235
const validateId = (node) => {
3336
const htmlForAttr = getProp(node.attributes, 'htmlFor');

src/util/hasAccessibleChild.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function hasAccessibleChild(node: JSXElement): boolean {
88
return node.children.some((child) => {
99
switch (child.type) {
1010
case 'Literal':
11+
case 'JSXText':
1112
return Boolean(child.value);
1213
case 'JSXElement':
1314
return !isHiddenFromScreenReader(

0 commit comments

Comments
 (0)