feat: [#2390] support the :required CSS pseudo-class - #2391
Open
marciomazza wants to merge 1 commit into
Open
Conversation
marciomazza
force-pushed
the
feat/pseudo-class-required
branch
from
September 8, 2026 14:03
ff36a33 to
e97d548
Compare
:required matches any form control carrying a required attribute (input, select, textarea), mirroring the existing :disabled handling in SelectorItem.
marciomazza
force-pushed
the
feat/pseudo-class-required
branch
from
September 8, 2026 14:19
e97d548 to
ec1d044
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves #2390
The
:requiredCSS pseudo-class is never matched —SelectorItem.matchPseudoItemhas no
requiredcase, so any:requiredselector silently returns nothing.Fix: add a
requiredcase mirroring the existingdisabledone — it matches whenthe element has a
requiredcontent attribute.Deviation left on purpose: this also matches
<input type="hidden" required>(the check is
'required' in element, not whether the attribute is applicable tothe element's current type), where browsers do not. The existing
:disabledcaseis equally loose; tightening both is out of scope here.
Tests
Added 1 test:
:requiredmatches<input>/<select>/<textarea>carryingthe attribute and skips an
<input>without it. Fails before / passes after.Full
npm testpasses.AI
I used Claude Code to write this, over multiple iterations. I guided and reviewed
it myself at every step.
Before submitting the PR, please make sure you do the following:
Tests
:requiredmatched<input required>,<select required>,<textarea required>, and did not match<input type="hidden" required>. The test asserts the first three.npm testlocally to make sure that all tests pass before submitting the PR.Title
feat,fix,choreorBREAKING CHANGE. The issue is optional and can be omitted if the pull request does not relate to an issue.AI tools