NEW286403
:has(:empty) still applied after the content is changed to not be empty
https://bugs.webkit.org/show_bug.cgi?id=286403
Summary :has(:empty) still applied after the content is changed to not be empty
Keavon
Reported 2025-01-22 20:40:20 PST
Minimal reproduction: Fiddle: https://jsfiddle.net/5n1tb2sd/ HTML: [<span>{<em></em>}</span>] CSS: span:has(em:empty) { color: red } JS: setTimeout(() => { document.querySelector("em").innerText = "no longer :empty so span shouldn't render this as red" }, 1000); The expected behavior is that the curly brackets start out red for the first second, then the text appears (making <em> no longer :empty) and everything should become black. This works in Chrome and Firefox. It is broken in Safari Version 18.1 (20619.2.8.11.10) which is the latest I can test through BrowserStack, it keeps the curly brackets and the added text red until I manage to force a repaint. Sometimes, merely opening dev tools causes it to repaint. Other times, I have to inspect the element and begin assigning it some CSS property or toggle an existing CSS property to force a repaint. To be clear, the red style is not applied to the <span> in dev tools, but it has been incorrectly painted red until the next repaint can be forced.
Attachments
Alexey Proskuryakov
Comment 1 2025-01-23 16:32:59 PST
Resizing the window doesn't make the issue go away, so this is more than a repaint issue.
Karl Dubost
Comment 2 2025-01-23 19:21:58 PST
That seems related/similar to Bug 286047
Radar WebKit Bug Importer
Comment 3 2025-01-29 20:42:07 PST
Note You need to log in before you can comment on or make changes to this bug.