Bug 267793

Summary: CSS container queries don't work with Shadow DOM :host selector
Product: WebKit Reporter: Sage Fennel <mail>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: annevk, eoconnor, karlcow, koivisto, rniwa, studio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=267046
Bug Depends on:    
Bug Blocks: 148695    
Attachments:
Description Flags
standalone HTML file used to reproduce the behavior none

Sage Fennel
Reported 2024-01-19 15:34:26 PST
Created attachment 469473 [details] standalone HTML file used to reproduce the behavior Safari's behavior around CSS container queries mixed with shadow DOM is different than both Chrome and Firefox. The short version of what I want to do is to use shadow DOM and put `:host { container: my-container-name; }` inside a style tag in shadow DOM, then use a `@container` query to respond to the size of the host element changing. I made a CodePen to reproduce the issue. You can load it in Safari 17 or Safari Technology Preview and reproduce the issue by resizing the browser horizontally. In Safari it seems that you need to put the `container` property on a different element besides `:host` for it to work. Admittedly, I'm not sure if Safari is following the spec correctly or not here. I mean, I can see how it seems a bit ambiguous whether that container name should actually be visible inside the shadow DOM since it's defined on an element that's technically outside of it. If this is actually spec compliant, I'm happy to close this issue and open issues with Chrome and Firefox instead. https://codepen.io/wavebeem/pen/RwdVvJO I've also included the full reproduction as a standalone HTML file in the attachments.
Attachments
standalone HTML file used to reproduce the behavior (2.42 KB, text/plain)
2024-01-19 15:34 PST, Sage Fennel
no flags
Radar WebKit Bug Importer
Comment 1 2024-01-19 16:20:50 PST
Egor Kloos
Comment 2 2024-01-23 12:15:40 PST
Looks like the same bug. Adding it here as a reference. https://bugs.webkit.org/show_bug.cgi?id=267046
Note You need to log in before you can comment on or make changes to this bug.