Implement correct :disabled
support for fieldsets and nested form controls
#125
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.
<fieldset>
considered:disabled
if it contains<legend>
jsdom/jsdom#3232With the current implementation of the
:disabled
selector, there are two main issues:legend
. Currently, the check for if the legend element contains the element doesn't handle if the first legend element doesn't exist in the fieldset. Specifically,(n=s.ancestor("fieldset",e))&&(n=s.first("legend",n))&&!n.contains(e))
returns false becausen=s.first("legend",n)
evaluates tonull
which is falsey, so the whole AND expression evaluates to false. Rather, if there is no legend element, we do not need to consider if the element is contained within the legend element and can solely focus on whether it is disabled or a descendant of a disabled fieldset.Since the original
test/w3c/html/semantics/selectors/pseudo-classes/disabled.html
web-platform-test was added, it has been updated with additional test-cases. So I have added those here to ensure this works correctly.