WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
304555
Named Style Container Queries on :host fail for Slotted Elements
https://bugs.webkit.org/show_bug.cgi?id=304555
Summary
Named Style Container Queries on :host fail for Slotted Elements
oscar7600
Reported
2025-12-20 16:26:41 PST
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
Attachments
Add attachment
proposed patch, testcase, etc.
Anthony Frehner
Comment 1
2025-12-24 11:51:41 PST
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
Radar WebKit Bug Importer
Comment 2
2025-12-27 16:27:12 PST
<
rdar://problem/167244007
>
Anthony Frehner
Comment 3
2025-12-27 16:51:40 PST
Also I plan on fixing this once the WPT addition is merged.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug