[REGRESSION] :checked pseudo-selector not working with dynamically inserted DOM elements
Categories
(Core :: DOM: Forms, defect)
Tracking
()
People
(Reporter: mic.gallego, Assigned: edgar)
References
(Regression, )
Details
(4 keywords)
Attachments
(6 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Steps to reproduce:
Hello,
We've started to have reports on our Shopify theme. Our CSS uses the :checked pseudo-selector to style a label. This works correctly when the DOM elements are in the initial page load, however the :checked selector stops working on elements dynamically inserted.
I've tried Browser Stack and the issue started to appear on Firefox 120 (so quite a long time ago, pretty surprised it did not get reported earlier). On versions prior it works correctly.
To reproduce the issue:
- Open this page (make sure to include the query param): https://www.ibbq.com/?preview_theme_id=144316825757
- For the product "Angara Maximus", click on "Choose options" to open the drawer.
Actual results:
Firefox (from version 120) does not match the :checked selector.
Expected results:
Firefox should match the selector.
Reporter | ||
Comment 1•2 months ago
|
||
Comment 2•2 months ago
|
||
Firefox (from version 120) does not match the :checked selector.
This is working fine for me on 135 (Nightly), and 128.5.3 (ESR), on macOS.
On which version and OS are you seeing the issue?
Reporter | ||
Comment 3•2 months ago
|
||
Hi,
This is broken on Firefox 133 (I've tried on Firefox 134 Beta and it is broken as well), both on MacOS. Make sure to try the link I have given (https://www.ibbq.com/?preview_theme_id=144316825757).
Comment 4•2 months ago
|
||
Unless I'm missing something obvious, seems correct to me with Firefox 133 on macOS 15.1.1 (24B91).
Does the behavior change if you start Firefox in Troubleshoot mode?
Comment 5•2 months ago
•
|
||
I think instructions to reproduce are incomplete.
https://www.ibbq.com/?preview_theme_id=144316825757
redirects me to https://www.ibbq.com/
(EDIT: although the page is different if I open the domain directly, so the URL might be misleading).
If I click on Angara Maximus
, it opens https://www.ibbq.com/products/angara-maximus
, which shows up correctly (previous screenshot).
I don't see the black border if I click on Quick view
in the homepage, which opens a sidebar.
Comment 6•2 months ago
•
|
||
I can reproduce the issue on Nightly135.0a1 Windows11.
No border appears for the checked radio button.
Regression window:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=0df79cc60ea0ef86258f3b33d533c75e91805d8b&tochange=16a3de29e4e69175f5a7c914ffa9de63b8683f2a
Regressed by: Bug 1685926
If Insert a form element encompassing the radio button elements and it will be rendered as expected.
Comment hidden (off-topic) |
Comment 8•2 months ago
|
||
:avandolder, since you are the author of the regressor, bug 1685926, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
Reporter | ||
Comment 9•2 months ago
|
||
Thanks for tracking down this bug. Can we expect a fix on the next version of Firefox? This is a regression on an extremely basic web feature, and it is impacting all users of our themes.
Assignee | ||
Comment 10•29 days ago
|
||
I can also reproduce this issue with the STR in comment #5. It seems like the radio input isn’t being "checked" at all. I dumped the input’s checked state in the console using document.getElementById("option-template--18409551233181__main--7213974388893-1-2").checked
, and it returned false
. When I manually set the checked state in the console using document.getElementById("option-template--18409551233181__main--7213974388893-1-2").checked = true
, the CSS updates correctly. This suggests that the issue is about the checked state not being updated correctly in certain cases.
Assignee | ||
Comment 11•29 days ago
|
||
I found a minimal test to reproduce the issue.
Assignee | ||
Comment 12•29 days ago
•
|
||
So, it seems that appending a checked radio input into a disconnected tree doesn’t update the checked state for other elements in the same radio group. Oh ugh, if it is appended to a disconnected form, the checked state for other elements in the same radio group DOES update.
Assignee | ||
Comment 13•28 days ago
|
||
I filed https://github.com/whatwg/html/issues/10897 to make it clear in the spec.
Assignee | ||
Updated•28 days ago
|
Assignee | ||
Updated•28 days ago
|
Assignee | ||
Updated•28 days ago
|
Updated•28 days ago
|
Assignee | ||
Comment 14•28 days ago
|
||
Assignee | ||
Comment 15•28 days ago
|
||
Assignee | ||
Comment 16•25 days ago
|
||
The (In reply to mic.gallego from comment #0)
- Open this page (make sure to include the query param): https://www.ibbq.com/?preview_theme_id=144316825757
Hi mic.gallego,
The link is no longer available, and I don’t see the same problem on other pages.
Has this issue been resolved on your side? Thanks!
Reporter | ||
Comment 17•25 days ago
|
||
Hello,
No, the issue is not fixed. It is a Firefox bug so I can't resolve it on my end :). You can reproduce it here as well: https://focal-theme-carbon.myshopify.com/
On the first row of products, hover on one of the products, click on the "Quick view" button to open the quick view, and see how checked radio are not checked as none of them are matching :checked selector.
Reporter | ||
Comment 18•25 days ago
|
||
Please find an attached video here: https://www.dropbox.com/s/re3d3mlnfko49i5/video.mov?dl=0
The first one shows Firefox (incorrect result), the second one shows Chrome (correct result).
Comment 19•22 days ago
|
||
Comment 21•21 days ago
|
||
bugherder |
Reporter | ||
Comment 22•21 days ago
|
||
Will this be backported to version 135?
Updated•21 days ago
|
Comment 25•21 days ago
|
||
The patch landed in nightly and beta is affected.
:edgar, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- If no, please set
status-firefox135
towontfix
.
For more information, please visit BugBot documentation.
Assignee | ||
Comment 26•20 days ago
|
||
See https://github.com/whatwg/html/issues/10897.
Original Revision: https://phabricator.services.mozilla.com/D233421
Updated•20 days ago
|
Comment 27•20 days ago
|
||
beta Uplift Approval Request
- User impact if declined: Radio inputs don’t work on some pages that use the Shopify theme due to this behavioral differences we have compared to other browsers.
- Code covered by automated testing: yes
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing: None
- Risk associated with taking this patch: Low
- Explanation of risk level: This only prevents the checkedness from updating when appending to a disconnected tree. There are many existing tests, and some new tests have also been added.
- String changes made/needed: None
- Is Android affected?: yes
Assignee | ||
Updated•20 days ago
|
Updated•19 days ago
|
Updated•19 days ago
|
Comment 28•19 days ago
|
||
uplift |
Updated•19 days ago
|
Updated•12 days ago
|
Description
•