<?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>303703</bug_id>
          
          <creation_ts>2025-12-07 01:07:16 -0800</creation_ts>
          <short_desc>Container style queries stop applying after user interaction when ancestor uses display: contents and defines the queried custom property</short_desc>
          <delta_ts>2025-12-07 03:58:38 -0800</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>DUPLICATE</resolution>
          <dup_id>301871</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>kobiz</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>koivisto</cc>
    
    <cc>moiseev.andy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2163950</commentid>
    <comment_count>0</comment_count>
    <who name="">kobiz</who>
    <bug_when>2025-12-07 01:07:16 -0800</bug_when>
    <thetext>When using a CSS container style query that depends on a custom property defined on an ancestor with display: contents, the styles inside the @container block initially apply correctly on load. After a simple user interaction (clicking the button), the styles inside the container style query stop applying.

This reproduces in Safari on iOS and Chrome on iOS (WebKit-based), but not in Chrome on desktop or Android (Blink).

This looks like a WebKit bug related to invalidation / reevaluation of container style queries when the container ancestor uses display: contents.


Steps to Reproduce:

```
&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta charset=&quot;utf-8&quot; /&gt;
  &lt;title&gt;WebKit container style query + display: contents bug&lt;/title&gt;
  &lt;style&gt;
    .preset-wrapper {
      display: contents;
      --preset: pink;
      /* In real code this element is a style container.
         Even in this simplified example, WebKit initially
         applies the style query correctly. */
    }

    .button {
      position: relative;
      width: 200px;
      height: 80px;
    }

    @container style(--preset: pink) {
      .button {
        background: pink;
        color: black;
      }
    }
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;div class=&quot;preset-wrapper&quot;&gt;
    &lt;button class=&quot;button&quot; id=&quot;btn-1&quot;&gt;Hello&lt;/button&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
```

1. Open the page in Safari
2. Observe the initial button style when the page loads.
3. Tap / click the button once.

Actual Results:

On initial load:
  The rules inside @container style(--preset: pink) are applied.
After clicking the button:
  The rules inside the container style query are no longer applied.

Expected Results:

The container style query @container style(--preset: pink) should continue to apply as long as the custom property --preset: pink remains in effect on the container ancestor.
A simple user interaction (click/focus/active state on a descendant button) should not cause container style queries to stop applying.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2163954</commentid>
    <comment_count>1</comment_count>
    <who name="">kobiz</who>
    <bug_when>2025-12-07 03:58:38 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 301871 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>