Closed Bug 1860373 Opened 1 year ago Closed 1 year ago

:has() Invalidation Doesn't Work with CSS Nesting

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 118
defect

Tracking

()

RESOLVED FIXED
121 Branch
Tracking Status
firefox121 --- fixed

People

(Reporter: dogatmidnight, Assigned: dshin)

References

Details

Crash Data

Attachments

(5 files)

Attached file input.html

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.

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.

Component: Untriaged → Layout: Form Controls
Product: Firefox → Core

The "about.config" parameter layout.css.has-selector.enabled is set to true.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Component: Layout: Form Controls → CSS Parsing and Computation
Duplicate of bug: 1792501
Resolution: --- → DUPLICATE

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.

Now that FF119 is out, I tested again – not fixed in my opinion (see test case below). Description: - Initially, "Europa" is `checked`, label `color: black; background-color: white`. That's correct. - Click on "Radtour": Europa has now label `color: black: background-color: blue`, "Radtour" has label `color: 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 label `color: black; background-color: white`. That's correct Testcase:
Attachment #9360213 - Attachment mime type: text/plain → text/html

I can repro comment 6 on nightly. David mind taking a look?

Blocks: has-pseudo
Status: RESOLVED → REOPENED
No longer duplicate of bug: 1792501
Ever confirmed: true
Flags: needinfo?(dshin)
Resolution: DUPLICATE → ---

Now that FF119 is out, I tested again – not fixed in my opinion (see test case attached ).

Description:

  • Initially, "Europa" is checked, label color: black; background-color: white. That's correct.
  • Click on "Radtour": Europa has now label color: black: background-color: blue, "Radtour" has label color: 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 label color: black; background-color: white. That's correct
Attached file Minimized Test Case

Ah, the new case has to do with interaction with nesting.

Flags: needinfo?(dshin)
Assignee: nobody → dshin
Severity: -- → S3
Summary: :has(input:checked) doesn't work → :has() Invalidation Doesn't Work with CSS Nesting

Should be reproducible without nesting too right? :is(.outer:has(.foo)) .bar or so.

Flags: needinfo?(dshin)

So that works if I replace the nested selector with:

:is(.outer:has(.foo)) .bar {
  background: purple;
}
Flags: needinfo?(dshin)

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.

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.

Pushed by dshin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2fd60169f484 Don't collapse invalidations from selectors shared by nesting. r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/42842 for changes under testing/web-platform/tests
Status: REOPENED → RESOLVED
Closed: 1 year ago1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch
Upstream PR merged by moz-wptsync-bot
Upstream PR was closed without merging
Duplicate of this bug: 1864938

Copying crash signatures from duplicate bugs.

Crash Signature: [@ <style::invalidation::element::invalidation_map::RelativeSelectorInnerDependencyCollector as selectors::visitor::SelectorVisitor>::visit_relative_selector_list] [@ selectors::parser::Component<T>::visit]
No longer duplicate of this bug: 1864938
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: