has selector stays frozen
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox119 | --- | fixed |
People
(Reporter: chriskirknielsen, Assigned: dshin)
References
(Regressed 1 open bug)
Details
(Keywords: perf-alert)
Attachments
(10 files, 2 obsolete files)
7.88 MB,
video/mp4
|
Details | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
Bug 1792501: Part 6 - :has invalidation for :empty and :nth (Without of). r=emilio,#layout-reviewers
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
343 bytes,
text/html
|
Details |
Cloned from bug #1792270, maybe be related.
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/105.0
Steps to reproduce:
- Enabled
layout.css.has-selector.enabled
in about:config - Set a background on the
html
element with CSS, create any element (e.g.<i>
), and a button. - Add JS to toggle a
test
class on the "any element",i
in this example, when clicked. - Set the CSS of the root to change the background when
.test
is found:html:has(.test)
- Click the button to toggle the class.
DEMO: https://codepen.io/chriskirknielsen/pen/eYryBpx (true existence of .test
is shown in the button with a simple sibling CSS selector, not has
)
Actual results:
Toggling class name on the queried element in has()
does not restyle the background. Furthermore:
- Firefox 105: I need to toggle background/overflow styles in the DevTools to trigger a reevaluation of the styles, or else they stay frozen
- Firefox Nightly 107: The technique used in Firefox 105 to reevaluate does not work,
html:has(.test)
never matches.
Expected results:
The background should change as the class is toggled, meaning :has()'s truthiness should react to that change accordingly.
Firefox 105: FAIL (:has matches inconsistently, )
Firefox Nightly 107: FAIL (:has never matches)
Safari 16: PASS
Chrome 105: PASS
Reporter | ||
Comment 1•3 years ago
|
||
Apologies, I had just updated Firefox Nightly and didn't realise the flag in about:config got reverted. Firefox Nightly 107.0a1 behaves just like Firefox 105 as far as I can tell.
Update:
Firefox 105: FAIL (:has matches inconsistently)
Firefox Nightly 107.0a1: FAIL (:has matches inconsistently)
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Comment 4•3 years ago
|
||
Another Issue related to this is, that when opening a case like this case (https://codepen.io/matuzo/pen/PoegGKV), where has is used to do things only in a temporary state like a modal is open, after getting the styles provided by has to wok (also possible by changing the value oft the property applied using has) stays applied even if the conditions made in the has-selector are not applied. Happens at lest in Firefox 105.
I can confirm that the implementation is partly done in JavaScript. From testing querySelector()
, it seems obvious that any of the selectors +
, ~
and >
are still unsupported as the starting symbol (html:has(i ~ button)
works, but i:has(~ button)
doesn't). Descendant matching (no symbol) is supported now.
Styles apply, yet Firefox doesn't yet evaluate matching the :has
pseudoclass aggressively.
The easiest you should do is this in the demo (the iframe's document
or any of its descendants be in focus):
console.assert(
document.querySelector("html:has(i ~ button) i") === document.querySelector("i:has(~ button"),
"Your browser does not yet have full support for the ':has()' selector!"
);
Comment 7•2 years ago
|
||
I just found the very same issue in Firefox 109.0, so can confirm. My test case is similar in that I'm also applying a class on an element using JavaScript (jQuery, to be more specific), and then am expecting that the :has() selector detects this change.
My selector is the following:
body:has(.dropdown-content.active) {
overflow: hidden;
}
In JavaScript I just add/remove the active
class to/from a <nav> element when user clicks the menu burger "button".
Compared against Google Chrome 109 (desktop and mobile) and it works there as expected (whenever .dropdown-content.active appears under body, page scrolling is disabled).
Assignee | ||
Comment 8•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 10•2 years ago
|
||
Assignee | ||
Comment 11•2 years ago
|
||
Assignee | ||
Comment 12•2 years ago
|
||
Assignee | ||
Comment 13•2 years ago
|
||
Assignee | ||
Comment 14•2 years ago
|
||
Assignee | ||
Comment 15•2 years ago
|
||
Assignee | ||
Comment 16•2 years ago
|
||
Assignee | ||
Comment 17•2 years ago
|
||
Assignee | ||
Comment 18•2 years ago
|
||
Depends on D185674
Updated•2 years ago
|
Comment 19•2 years ago
|
||
This is the "display: none" case discussed offline.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 21•2 years ago
|
||
Comment 22•2 years ago
|
||
Backed out for causing wpt failures on /css/selectors/...
Backout link: https://hg.mozilla.org/integration/autoland/rev/efd00170d5228445ceb123c48bfcfa7656331feb
Failure log WR -> TEST-UNEXPECTED-FAIL | /css/selectors/invalidation/nth-child-of-attr.html
Comment 24•2 years ago
|
||
Comment 25•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/1746b0d41da4
https://hg.mozilla.org/mozilla-central/rev/65999f9a344c
https://hg.mozilla.org/mozilla-central/rev/af0f8eaebfc1
https://hg.mozilla.org/mozilla-central/rev/2fa142acab00
https://hg.mozilla.org/mozilla-central/rev/f601de4d577c
https://hg.mozilla.org/mozilla-central/rev/b1aa6a98b0fc
https://hg.mozilla.org/mozilla-central/rev/4b261890418a
https://hg.mozilla.org/mozilla-central/rev/80b1c6393b00
Comment 30•2 years ago
|
||
(In reply to Sandor Molnar from comment #22)
Backed out for causing wpt failures on /css/selectors/...
Backout link: https://hg.mozilla.org/integration/autoland/rev/efd00170d5228445ceb123c48bfcfa7656331feb
Failure log WR -> TEST-UNEXPECTED-FAIL | /css/selectors/invalidation/nth-child-of-attr.html
== Change summary for alert #39616 (as of Wed, 20 Sep 2023 05:06:10 GMT) ==
Regressions:
Ratio | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|
0.34% | installer size | osx-aarch64-shippable | aarch64 nightly | 83,539,506.50 -> 83,822,874.25 |
0.31% | installer size | osx-aarch64-shippable | aarch64 nightly | 83,509,832.83 -> 83,766,753.67 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=39616
Updated•2 years ago
|
Description
•