<?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>304555</bug_id>
          
          <creation_ts>2025-12-20 16:26:41 -0800</creation_ts>
          <short_desc>Named Style Container Queries on :host fail for Slotted Elements</short_desc>
          <delta_ts>2026-01-08 18:40:42 -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>macOS 26</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=289868</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=295838</see_also>
          <bug_file_loc>https://lit.dev/playground/#gist=8601556f4a13e49eb85743791f21157d</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>148695</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter>oscar7600</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>afrehner.work</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>woodlxf00</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2167583</commentid>
    <comment_count>0</comment_count>
    <who name="">oscar7600</who>
    <bug_when>2025-12-20 16:26:41 -0800</bug_when>
    <thetext>Safari 26.2 now resolves container-name matching regardless of origin, a discrepancy remains: named style container queries defined on :host are not applied to slotted elements.

While unnamed queries were recently fixed for the composed tree, https://github.com/WebKit/WebKit/commit/a20439aa1afd56e3b8e0f4af7c899ac98237fa3d, the same logic fails in Safari when a container-name is involved. 

Currently, ✅Chrome correctly evaluates the query,  but ❌Safari (26.2 and Safari Technology Preview 234) requires the container to be defined in the Light DOM to work.


Reproduction:

 https://lit.dev/playground/#gist=8601556f4a13e49eb85743791f21157d

Steps to reproduce:

1. Open the playground in **Safari** and **Chrome**.
2. Observe that in Safari, the background color is **not** applied to the slotted element.
3. In `index.html`, uncomment the following block:

```css
parent-element {
  /* container-name: slotted; */
}

```

4. Notice it now works in Safari. This confirms the issue only exists when the container is defined via `:host` in the Shadow DOM.

- Expected Behavior: Slotted elements should resolve container queries against a named container defined on the `:host`

- Actual Behavior (Safari): Slotted elements ignore named containers defined on `:host`



References

- Related Fix: https://github.com/WebKit/WebKit/commit/a20439aa1afd56e3b8e0f4af7c899ac98237fa3d

- Relevant Commit: https://github.com/WebKit/WebKit/commit/efd4ebe98cab2bbb385ffe1e1e40d3870917727b

- Container-names are tree-scoped: https://bugs.webkit.org/show_bug.cgi?id=289868</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2168094</commentid>
    <comment_count>1</comment_count>
    <who name="Anthony Frehner">afrehner.work</who>
    <bug_when>2025-12-24 11:51:41 -0800</bug_when>
    <thetext>Was able to get this down to a bare reproduction; I have a PR up to WPT to add this test case here https://github.com/web-platform-tests/wpt/pull/56899</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2168374</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-12-27 16:27:12 -0800</bug_when>
    <thetext>&lt;rdar://problem/167244007&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2168377</commentid>
    <comment_count>3</comment_count>
    <who name="Anthony Frehner">afrehner.work</who>
    <bug_when>2025-12-27 16:51:40 -0800</bug_when>
    <thetext>Also I plan on fixing this once the WPT addition is merged.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>