<?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>301871</bug_id>
          
          <creation_ts>2025-11-03 10:19:30 -0800</creation_ts>
          <short_desc>CSS Container Style Queries: fails when container has display: contents</short_desc>
          <delta_ts>2026-05-21 09:55:54 -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 26</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=306237</see_also>
    
    <see_also>https://github.com/web-platform-tests/wpt/pull/60070</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Steve Orvell">steveorvell</reporter>
          <assigned_to name="Ahmad Saleem">ahmad.saleem792</assigned_to>
          <cc>joel</cc>
    
    <cc>karlcow</cc>
    
    <cc>kobiz</cc>
    
    <cc>koivisto</cc>
    
    <cc>maggotfish</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2156014</commentid>
    <comment_count>0</comment_count>
      <attachid>477264</attachid>
    <who name="Steve Orvell">steveorvell</who>
    <bug_when>2025-11-03 10:19:30 -0800</bug_when>
    <thetext>Created attachment 477264
container style query with display contents

Given the following setup:

1. a container defines a CSS custom property and has `display: contents`
2. a style query uses the custom property to apply a property to a contained element
3. the contained element changes styling dynamically, e.g. via a :hover rule applying

Expected: the contained element maintains the property set via the container style query.

Actual: the contained element loses the property set via the container style query.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2156015</commentid>
    <comment_count>1</comment_count>
    <who name="Steve Orvell">steveorvell</who>
    <bug_when>2025-11-03 10:20:38 -0800</bug_when>
    <thetext>Reproduction: https://lit.dev/playground/#gist=e84af8138bb40c026ad3806be64ee227</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2157702</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-11-10 10:20:13 -0800</bug_when>
    <thetext>&lt;rdar://problem/164414720&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2158456</commentid>
    <comment_count>3</comment_count>
    <who name="Yehonatan Daniv">maggotfish</who>
    <bug_when>2025-11-12 23:03:14 -0800</bug_when>
    <thetext>This is also affecting us at Wix with future stuff we want to build, not really affecting current sites, but it&apos;s blocking us.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2158458</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-11-12 23:24:01 -0800</bug_when>
    <thetext>Thanks Steve and Yehonatan
I can reproduce the issue on latest Safari and STP 231.

The second block loose the background-color after the hover.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2163955</commentid>
    <comment_count>5</comment_count>
    <who name="">kobiz</who>
    <bug_when>2025-12-07 03:58:38 -0800</bug_when>
    <thetext>*** Bug 303703 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2210133</commentid>
    <comment_count>6</comment_count>
    <who name="Joel Drapper">joel</who>
    <bug_when>2026-05-12 07:43:30 -0700</bug_when>
    <thetext>I found a workaround. If you set a property when interacting with an element inside the `display: contents` element, it seems to sufficiently force Safari to apply the container query again.

  .contents {
    display: contents;
    --contents-cache-key: 0;

    &amp;:has(:hover) {
      --contents-cache-key: 0;
    }

    &amp;:has(:focus-within) {
      --contents-cache-key: 0;
    }

    &amp;:has(:active) {
      --contents-cache-key: 0;
    }
  }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2211591</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-05-17 18:59:14 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/65081</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2212978</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-05-21 09:46:27 -0700</bug_when>
    <thetext>Committed 313677@main (93785137d0d1): &lt;https://commits.webkit.org/313677@main&gt;

Reviewed commits have been landed. Closing PR #65081 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>477264</attachid>
            <date>2025-11-03 10:19:30 -0800</date>
            <delta_ts>2025-11-03 10:19:30 -0800</delta_ts>
            <desc>container style query with display contents</desc>
            <filename>file_301871.txt</filename>
            <type>text/plain</type>
            <size>317</size>
            <attacher name="Steve Orvell">steveorvell</attacher>
            
              <data encoding="base64">PHN0eWxlPg0KICAudGVzdDpob3ZlciB7DQogICAgb3V0bGluZTogMXB4IHNvbGlkOw0KICB9DQog
IEBjb250YWluZXIgc3R5bGUoLS1ncmVlbikgew0KICAgIC50ZXN0IHsNCiAgICAgIGJhY2tncm91
bmQ6IHBhbGVncmVlbjsNCiAgICB9DQogIH0NCjwvc3R5bGU+DQo8ZGl2IHN0eWxlPSItLWdyZWVu
OiA7Ij4NCiAgPGRpdiBjbGFzcz0idGVzdCI+aG92ZXIgbWU8L2Rpdj4NCjwvZGl2Pg0KPGJyPg0K
PGRpdiBzdHlsZT0iLS1ncmVlbjogOyBkaXNwbGF5OiBjb250ZW50czsiPg0KICA8ZGl2IGNsYXNz
PSJ0ZXN0Ij5ob3ZlciBtZTwvZGl2Pg0KPC9kaXY+DQo=
</data>

          </attachment>
      

    </bug>

</bugzilla>