WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
276771
#a:not(:has(#b)) doesn't rerender when #b is added to #a
https://bugs.webkit.org/show_bug.cgi?id=276771
Summary
#a:not(:has(#b)) doesn't rerender when #b is added to #a
Luca Casonato
Reported
2024-07-18 04:08:36 PDT
Created
attachment 471915
[details]
reproduction.html Take an element with id #hey: ```html <div id="hey" width=100 height=100></div> ``` And the following CSS: ```css #hey:not(:has(div)) { background: red; } ``` This element should have a red background as long as it has no `div` children. Now use the following HTML to add a child: ```js const div = document.createElement('div'); div.innerHTML = 'Hello World'; hey.appendChild(div); `` You would expect the red background to disappear, and only the text to remain. However, in WebKit the text appears, but red background does not disappear. Once the element is forced to re-compute styles for unrelated reasons, like adding a `style:="color: blue"` attribute to the element, the red background correctly disappears. It seems like WebKit is not correctly watching the DOM under #hey to determine when a selector needs to be recomputed. See the attached reproduction. It will append the div after 1 second. Pressing the "Re-render" buton will add a class that causes all styles to be re-computed.
Attachments
reproduction.html
(486 bytes, text/plain)
2024-07-18 04:08 PDT
,
Luca Casonato
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-07-23 16:39:35 PDT
<
rdar://problem/132361847
>
Matthieu Dubet
Comment 2
2024-08-12 15:19:01 PDT
Thank you for the bug report. It seems that we have an issue with invalidation of :not(:has(foo)) indeed. We will look into it.
Matthieu Dubet
Comment 3
2024-08-20 11:40:56 PDT
***
Bug 277230
has been marked as a duplicate of this bug. ***
fuad.tariq@yahoo.com
Comment 4
2024-11-15 07:23:36 PST
Is this bug resolved yet? If not, can we get an update when it is resolved and on which version? It's annoying not having this working as it forces me to write convoluted CSS rather than simple to understand CSS (i.e., "if div not has..." is so much easier to comprehend than unnecessarily setting the default CSS in "if div has..." and having the regular div CSS be the not has).
Matthieu Dubet
Comment 5
2024-12-14 01:51:21 PST
The bug has been resolved indeed. You can follow Safari Technology Preview updates to test whether your website works with the fix
https://developer.apple.com/safari/technology-preview/
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug