Repository navigation
Match controls disabled by an ancestor fieldset #1913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,11 @@ | |
| const textControl = | ||
| "input:is([type=text i],[type=search i],[type=url i],[type=tel i],[type=email i],[type=password i],[type=date i],[type=month i],[type=week i],[type=time i],[type=datetime-local i],[type=number i])"; | ||
|
|
||
| const disabledByFieldset = `:is( | ||
| fieldset[disabled] > :not(legend:first-of-type), | ||
| fieldset[disabled] > :not(legend:first-of-type) * | ||
| )`; | ||
|
|
||
| /** | ||
| * Aliases are pseudos that are expressed as selectors. | ||
| */ | ||
|
|
@@ -20,9 +25,10 @@ export const aliases: Record<string, string> = { | |
|
|
||
| // https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements | ||
| disabled: `:is( | ||
| :is(button, input, select, textarea, optgroup, option)[disabled], | ||
| :is(button, input, select, textarea, optgroup, option, fieldset)[disabled], | ||
| optgroup[disabled] > option, | ||
| fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *) | ||
| :is(button, input, select, textarea, fieldset)${disabledByFieldset}, | ||
| :is(optgroup, option):is(select[disabled] *, select${disabledByFieldset} *) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For Useful? React with 👍 / 👎. |
||
| )`, | ||
| enabled: | ||
| ":is(button, input, select, textarea, optgroup, option, fieldset):not(:disabled)", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
<select disabled><option>X</option></select>, this branch makes theoptionmatch:disabledinstead of:enabled. Options do not inherit a select's disabled state. Anoptionis disabled by its own attribute or a disabled parentoptgroup; anoptgroupneeds its own attribute.The same mistake occurs when a fieldset disables the select, so callers get the wrong query results in both cases. Remove this branch and update the tests that expect inherited state.