<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>239868</bug_id>
          
          <creation_ts>2022-04-28 13:30:09 -0700</creation_ts>
          <short_desc>[:has() pseudo-class] is flaky when passing a selector that contains :empty</short_desc>
          <delta_ts>2025-09-09 06:04:37 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari 15</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>227702</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Bruno Silva">brsil</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>christian</cc>
    
    <cc>koivisto</cc>
    
    <cc>lwarlow</cc>
    
    <cc>ntim</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1865241</commentid>
    <comment_count>0</comment_count>
      <attachid>458545</attachid>
    <who name="Bruno Silva">brsil</who>
    <bug_when>2022-04-28 13:30:09 -0700</bug_when>
    <thetext>Created attachment 458545
Test page showing the issue where :has() is not triggering a update

While using the pseudo class selector :has() in combination with the ::after pseudo-element and passing a selector to the :has that contains the :empty pseudo class I get a flaky behavior where making a change that would make the selector passed to the :has() be invalid does not actually invalidate the selector that has the :has() resulting in a flaky behavior.

To see the behavior in action on the attached test page do the following steps:
1. Click on the add child button
   1.1. You should see a child that is not empty and has a random number or,
   1.2. A child that has no content and the text &quot;::after text&quot; is displayed from the ::after element on the parent
2. If you got a empty child now click on the add text button

Expected:
The child is now not empty therefore the selector &quot;.parent:has(.child:only-child:empty)::after&quot; is invalid and the &quot;::after text&quot; should disappear from the parent element

Currently:
The &quot;::after text&quot; is still present on the parent and has no selector matching it</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1865273</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-04-28 15:43:56 -0700</bug_when>
    <thetext>&lt;rdar://problem/92492066&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1872731</commentid>
    <comment_count>2</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2022-05-30 05:12:57 -0700</bug_when>
    <thetext>Seems more of a layout update issue than style, resizing the page makes the bug go away.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926578</commentid>
    <comment_count>3</comment_count>
    <who name="">christian</who>
    <bug_when>2023-01-19 05:05:01 -0800</bug_when>
    <thetext>I see the same thing.

Trying to hide a wrapper-div if no ad is injected in it. This doesn&apos;t work, although the correct :has() style is set on the wrapper, if you look in the inspector, the style isn&apos;t applied before a repaint is forced.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926596</commentid>
    <comment_count>4</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2023-01-19 06:31:57 -0800</bug_when>
    <thetext>Actually I think we lack :has() aware invalidation for :empty.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1926815</commentid>
    <comment_count>5</comment_count>
    <who name="">christian</who>
    <bug_when>2023-01-19 23:22:28 -0800</bug_when>
    <thetext>(In reply to Antti Koivisto from comment #4)
&gt; Actually I think we lack :has() aware invalidation for :empty.

I did some further tests, and I think you&apos;re right.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>458545</attachid>
            <date>2022-04-28 13:30:09 -0700</date>
            <delta_ts>2022-04-28 16:10:21 -0700</delta_ts>
            <desc>Test page showing the issue where :has() is not triggering a update</desc>
            <filename>file_239868.html</filename>
            <type>text/html</type>
            <size>1694</size>
            <attacher name="Bruno Silva">brsil</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+DQo8aHRtbCBsYW5nPSJlbiI+DQogIDxoZWFkPg0KICAgIDxtZXRhIGNo
YXJzZXQ9IlVURi04IiAvPg0KICAgIDx0aXRsZT46aGFzKCkgaXNzdWU8L3RpdGxlPg0KICAgIDxz
dHlsZT4NCiAgICAgICNjb250ZW50IHsNCiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogYmx1ZTsN
CiAgICAgIH0NCg0KICAgICAgLnBhcmVudCB7DQogICAgICAgIGJhY2tncm91bmQtY29sb3I6IGZ1
Y2hzaWE7DQogICAgICAgIHdpZHRoOiAxMDAlOw0KICAgICAgICBmb250LXNpemU6IDJlbTsNCiAg
ICAgIH0NCg0KICAgICAgYnV0dG9uIHsNCiAgICAgICAgdGV4dC1hbGlnbjogY2VudGVyOw0KICAg
ICAgICB3aWR0aDogMTAwJTsNCiAgICAgIH0NCg0KICAgICAgLnBhcmVudDpoYXMoLmNoaWxkOm9u
bHktY2hpbGQ6ZW1wdHkpOjphZnRlciB7DQogICAgICAgIGNvbnRlbnQ6ICI6OmFmdGVyIHRleHQi
Ow0KICAgICAgICBjb2xvcjogeWVsbG93Ow0KICAgICAgfQ0KICAgIDwvc3R5bGU+DQogIDwvaGVh
ZD4NCiAgPGJvZHk+DQogICAgPGRpdiBpZD0iY29udGVudCIgY29udGVudGVkaXRhYmxlPSJ0cnVl
Ij48L2Rpdj4NCiAgICA8YnV0dG9uIGlkPSJhZGRDaGlsZCI+QWRkIGNoaWxkPC9idXR0b24+DQog
ICAgPGJ1dHRvbiBpZD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ChjaGlsZHJlbi5sZW5ndGgg
PiAwKSB7DQogICAgICAgICAgY29uc3QgbGFzdENoaWxkID0gY2hpbGRyZW5bY2hpbGRyZW4ubGVu
Z3RoIC0gMV07DQogICAgICAgICAgY29uc3QgbnVtYmVyID0gTWF0aC5yYW5kb20oKTsNCiAgICAg
ICAgICBsYXN0Q2hpbGQuaW5uZXJUZXh0ID0gbnVtYmVyICsgIiI7DQogICAgICAgIH0NCiAgICAg
IH0pOw0KICAgIDwvc2NyaXB0Pg0KICA8L2JvZHk+DQo8L2h0bWw+DQo=
</data>

          </attachment>
      

    </bug>

</bugzilla>