:has() Invalidation Doesn't Work with CSS Nesting
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox121 | --- | fixed |
People
(Reporter: dogatmidnight, Assigned: dshin)
References
Details
Crash Data
Attachments
(5 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/118.0
Steps to reproduce:
See attached HTML. It uses the "hidden checkbox" trick so that clicking on a label ("Berlin", "London", or "Paris") should change the color of the #result div.
The CSS relies on the :has() function for this, but the corresponding rule is never triggered.
In developer tools, the first click on any not checked label results in a color change if the div element is selected in the inspector.
Actual results:
The color of #result remains blue, regardless of the checked state of the input elements. Clicking on a label does change the checked property. Also, removing the div around the input and label elements and adjusting the corresponding styles to
input#tab1:checked ~ #result {
background-color: blue;
}
input#tab2:checked ~ #result {
background-color: green;
}
input#tab3:checked ~ #result {
background-color: red;
}
(i.e. effectively removing the :has() function) makes the HTML behave as expected, i.e. color is changed on label click.
Expected results:
Chrome and Safari show the correct behavior:
The div is initially blue. Clicking on "London" changes it to green, clicking on "Paris" to red and on "Berlin" to blue again.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Layout: Form Controls' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Reporter | ||
Comment 2•1 year ago
|
||
The "about.config" parameter layout.css.has-selector.enabled is set to true.
Reporter | ||
Comment 4•1 year ago
|
||
The bug that this one is a duplicate of has been closed. While apparently, it is not fixed (otherwise, I'd not have encountered the described issue).
Judging from your using agent string, you are using Firefox 118 and not 119. Thanks for the report anyway.
Reporter | ||
Comment 6•1 year ago
|
||
Updated•1 year ago
|
Comment 7•1 year ago
|
||
I can repro comment 6 on nightly. David mind taking a look?
Reporter | ||
Comment 8•1 year ago
|
||
Reporter | ||
Comment 9•1 year ago
|
||
Now that FF119 is out, I tested again – not fixed in my opinion (see test case attached ).
Description:
- Initially, "Europa" is
checked
, labelcolor: black; background-color: white
. That's correct. - Click on "Radtour": Europa has now label
color: black: background-color: blue
, "Radtour" has labelcolor: white; background-color: white
.That's not correct. - Click anywhere in Developer tools window: Europa has now label
color: white; background-color: blue
and "Radtour" has labelcolor: black; background-color: white
. That's correct
Assignee | ||
Comment 10•1 year ago
|
||
Ah, the new case has to do with interaction with nesting.
Assignee | ||
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Should be reproducible without nesting too right? :is(.outer:has(.foo)) .bar
or so.
Assignee | ||
Comment 12•1 year ago
|
||
So that works if I replace the nested selector with:
:is(.outer:has(.foo)) .bar {
background: purple;
}
Comment 13•1 year ago
|
||
Is the has invalidation set somehow getting built before replacing the nesting selector? That seems wrong if so, but I don't see how that could happen.
Assignee | ||
Comment 14•1 year ago
•
|
||
Ah, this is indeed an issue on relative selector invalidation end... We use a map hashed by relative selector pointer + the invalidation it generates to collapse duplicate invalidations into one. Since .outer:has(.foo)
and & .bar
share the has
selector at pointer level, they are considered the same, and we think these two are duplicate of each other when it's not.
Assignee | ||
Comment 15•1 year ago
|
||
Comment 16•1 year ago
|
||
Comment 18•1 year ago
|
||
bugherder |
Comment 22•1 year ago
|
||
Copying crash signatures from duplicate bugs.
Description
•