<?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>267793</bug_id>
          
          <creation_ts>2024-01-19 15:34:26 -0800</creation_ts>
          <short_desc>CSS container queries don&apos;t work with Shadow DOM :host selector</short_desc>
          <delta_ts>2024-01-29 23:52:43 -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 17</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=267046</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>
          
          <blocked>148695</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Sage Fennel">mail</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>eoconnor</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>rniwa</cc>
    
    <cc>studio</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2006271</commentid>
    <comment_count>0</comment_count>
      <attachid>469473</attachid>
    <who name="Sage Fennel">mail</who>
    <bug_when>2024-01-19 15:34:26 -0800</bug_when>
    <thetext>Created attachment 469473
standalone HTML file used to reproduce the behavior

Safari&apos;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&apos;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&apos;s defined on an element that&apos;s technically outside of it. If this is actually spec compliant, I&apos;m happy to close this issue and open issues with Chrome and Firefox instead.

https://codepen.io/wavebeem/pen/RwdVvJO

I&apos;ve also included the full reproduction as a standalone HTML file in the attachments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2006281</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-01-19 16:20:50 -0800</bug_when>
    <thetext>&lt;rdar://problem/121289354&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2006949</commentid>
    <comment_count>2</comment_count>
    <who name="Egor Kloos">studio</who>
    <bug_when>2024-01-23 12:15:40 -0800</bug_when>
    <thetext>Looks like the same bug. Adding it here as a reference. 
https://bugs.webkit.org/show_bug.cgi?id=267046</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>469473</attachid>
            <date>2024-01-19 15:34:26 -0800</date>
            <delta_ts>2024-01-19 15:34:26 -0800</delta_ts>
            <desc>standalone HTML file used to reproduce the behavior</desc>
            <filename>file_267793.txt</filename>
            <type>text/plain</type>
            <size>2481</size>
            <attacher name="Sage Fennel">mail</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+DQo8aHRtbCBsYW5nPSJlbiI+DQogIDxoZWFkPg0KICAgIDxtZXRhIGNo
YXJzZXQ9IlVURi04IiAvPg0KICAgIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0
aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwtc2NhbGU9MS4wIiAvPg0KICAgIDx0aXRsZT5Eb2N1bWVu
dDwvdGl0bGU+DQogICAgPHNjcmlwdCB0eXBlPSJtb2R1bGUiPg0KICAgICAgY29uc3QgaHRtbCA9
IFN0cmluZy5yYXc7DQoNCiAgICAgIGNsYXNzIEJhc2UgZXh0ZW5kcyBIVE1MRWxlbWVudCB7DQog
ICAgICAgIGNvbnN0cnVjdG9yKCkgew0KICAgICAgICAgIHN1cGVyKCk7DQogICAgICAgICAgdGhp
cy5hdHRhY2hTaGFkb3coeyBtb2RlOiAib3BlbiIgfSk7DQogICAgICAgIH0NCiAgICAgIH0NCg0K
ICAgICAgY2xhc3MgWENvbnRhaW5lcjEgZXh0ZW5kcyBCYXNlIHsNCiAgICAgICAgY29ubmVjdGVk
Q2FsbGJhY2soKSB7DQogICAgICAgICAgdGhpcy5zaGFkb3dSb290LmlubmVySFRNTCA9IGh0bWxg
DQogICAgICAgICAgICA8c3R5bGU+DQogICAgICAgICAgICAgIDpob3N0IHsNCiAgICAgICAgICAg
ICAgICBkaXNwbGF5OiBibG9jazsNCiAgICAgICAgICAgICAgICBjb250YWluZXI6IG15LWNvbnRh
aW5lcjsNCiAgICAgICAgICAgICAgICBjb250YWluZXItdHlwZTogaW5saW5lLXNpemU7DQogICAg
ICAgICAgICAgIH0NCg0KICAgICAgICAgICAgICAuYm94IHsNCiAgICAgICAgICAgICAgICBiYWNr
Z3JvdW5kOiBibHVlOw0KICAgICAgICAgICAgICAgIG1heC13aWR0aDogbWF4LWNvbnRlbnQ7DQog
ICAgICAgICAgICAgICAgYXNwZWN0LXJhdGlvOiAxIC8gMTsNCiAgICAgICAgICAgICAgICBwYWRk
aW5nOiAxcmVtOw0KICAgICAgICAgICAgICAgIGNvbG9yOiB3aGl0ZTsNCiAgICAgICAgICAgICAg
fQ0KDQogICAgICAgICAgICAgIEBjb250YWluZXIgbXktY29udGFpbmVyIChtaW4td2lkdGg6IDQw
MHB4KSB7DQogICAgICAgICAgICAgICAgLmJveCB7DQogICAgICAgICAgICAgICAgICBiYWNrZ3Jv
dW5kOiByZWQ7DQogICAgICAgICAgICAgICAgICBvdXRsaW5lOiAycHggc29saWQ7DQogICAgICAg
ICAgICAgICAgICBvdXRsaW5lLW9mZnNldDogLTRweDsNCiAgICAgICAgICAgICAgICB9DQogICAg
ICAgICAgICAgIH0NCiAgICAgICAgICAgIDwvc3R5bGU+DQogICAgICAgICAgICA8ZGl2IGNsYXNz
PSJib3giPiR7dGhpcy5sb2NhbE5hbWV9PC9kaXY+DQogICAgICAgICAgYDsNCiAgICAgICAgfQ0K
ICAgICAgfQ0KDQogICAgICBjbGFzcyBYQ29udGFpbmVyMiBleHRlbmRzIEJhc2Ugew0KICAgICAg
ICBjb25uZWN0ZWRDYWxsYmFjaygpIHsNCiAgICAgICAgICB0aGlzLnNoYWRvd1Jvb3QuaW5uZXJI
VE1MID0gaHRtbGANCiAgICAgICAgICAgIDxzdHlsZT4NCiAgICAgICAgICAgICAgOmhvc3Qgew0K
ICAgICAgICAgICAgICAgIGRpc3BsYXk6IGJsb2NrOw0KICAgICAgICAgICAgICB9DQoNCiAgICAg
ICAgICAgICAgLndyYXBwZXIgew0KICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogbXktY29udGFp
bmVyOw0KICAgICAgICAgICAgICAgIGNvbnRhaW5lci10eXBlOiBpbmxpbmUtc2l6ZTsNCiAgICAg
ICAgICAgICAgfQ0KDQogICAgICAgICAgICAgIC5ib3ggew0KICAgICAgICAgICAgICAgIGJhY2tn
cm91bmQ6IGdyZWVuOw0KICAgICAgICAgICAgICAgIG1heC13aWR0aDogbWF4LWNvbnRlbnQ7DQog
ICAgICAgICAgICAgICAgYXNwZWN0LXJhdGlvOiAxIC8gMTsNCiAgICAgICAgICAgICAgICBwYWRk
aW5nOiAxcmVtOw0KICAgICAgICAgICAgICAgIGNvbG9yOiB3aGl0ZTsNCiAgICAgICAgICAgICAg
fQ0KDQogICAgICAgICAgICAgIEBjb250YWluZXIgbXktY29udGFpbmVyIChtaW4td2lkdGg6IDQw
MHB4KSB7DQogICAgICAgICAgICAgICAgLmJveCB7DQogICAgICAgICAgICAgICAgICBiYWNrZ3Jv
dW5kOiBwdXJwbGU7DQogICAgICAgICAgICAgICAgICBvdXRsaW5lOiAycHggc29saWQ7DQogICAg
ICAgICAgICAgICAgICBvdXRsaW5lLW9mZnNldDogLTRweDsNCiAgICAgICAgICAgICAgICB9DQog
ICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIDwvc3R5bGU+DQogICAgICAgICAgICA8ZGl2IGNs
YXNzPSJ3cmFwcGVyIj4NCiAgICAgICAgICAgICAgPGRpdiBjbGFzcz0iYm94Ij4ke3RoaXMubG9j
YWxOYW1lfTwvZGl2Pg0KICAgICAgICAgICAgPC9kaXY+DQogICAgICAgICAgYDsNCiAgICAgICAg
fQ0KICAgICAgfQ0KDQogICAgICBjdXN0b21FbGVtZW50cy5kZWZpbmUoIngtY29udGFpbmVyMSIs
IFhDb250YWluZXIxKTsNCiAgICAgIGN1c3RvbUVsZW1lbnRzLmRlZmluZSgieC1jb250YWluZXIy
IiwgWENvbnRhaW5lcjIpOw0KICAgIDwvc2NyaXB0Pg0KICA8L2hlYWQ+DQogIDxib2R5Pg0KICAg
IDx4LWNvbnRhaW5lcjE+PC94LWNvbnRhaW5lcjE+DQogICAgPHgtY29udGFpbmVyMj48L3gtY29u
dGFpbmVyMj4NCiAgPC9ib2R5Pg0KPC9odG1sPg0K
</data>

          </attachment>
      

    </bug>

</bugzilla>