Skip to content

Commit b95ebd2

Browse files
author
Courtney Nguyen
committed
Updated wording, added additional tests
1 parent b2cfb4b commit b95ebd2

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

__tests__/src/rules/no-disabled-test.js

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ ruleTester.run('no-disabled', rule, {
3939
].map(parserOptionsMapper),
4040
invalid: [
4141
{ code: '<input disabled />', errors: [expectedWarning] },
42+
{ code: '<input disabled="true" />', errors: [expectedWarning] },
43+
{ code: '<input disabled="false" />', errors: [expectedWarning] },
4244
{ code: '<button disabled />', errors: [expectedWarning] },
4345
{ code: '<select disabled />', errors: [expectedWarning] },
4446
{ code: '<textarea disabled />', errors: [expectedWarning] },

docs/rules/no-disabled.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
# no-disabled
22

3-
Enforce that `disabled` prop is not used on elements. Disabling interactive elements removes the element from the accessibility tree. Use `aria-disabled` instead.
3+
Rule that `disabled` prop should be cautioned on elements. Disabling interactive elements removes the element from the accessibility tree. Consider using `aria-disabled`.
44

55
## Rule details
66

7-
This rule takes one optional object argument of type object:
8-
9-
```json
10-
{
11-
"rules": {
12-
"jsx-a11y/no-disabled": [ 2, {
13-
"ignoreNonDOM": true
14-
}],
15-
}
16-
}
17-
```
18-
19-
For the `ignoreNonDOM` option, this determines if developer created components are checked.
7+
Warns usage of `disabled` property.
208

219
### Succeed
2210
```jsx
11+
<div />
12+
<div disabled />
2313
<input />
14+
<select />
15+
<textarea />
16+
<button />
2417
```
2518

2619
### Fail
@@ -36,3 +29,4 @@ General best practice (reference resources)
3629

3730
### Resources
3831
- [MDN aria-disabled](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled)
32+
- [W3 KBD Disabled Controls](https://www.w3.org/TR/wai-aria-practices/#kbd_disabled_controls)

0 commit comments

Comments
 (0)