<?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>307982</bug_id>
          
          <creation_ts>2026-02-16 06:33:05 -0800</creation_ts>
          <short_desc>REGRESSION (17.4-26): `@scope` with custom-element scope root stops applying to `:scope` and descendants</short_desc>
          <delta_ts>2026-05-07 09:14:32 -0700</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>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>308330</dup_id>
          
          <bug_file_loc>https://jsfiddle.net/m7dbr8zw/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>devhassan941</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2182060</commentid>
    <comment_count>0</comment_count>
    <who name="">devhassan941</who>
    <bug_when>2026-02-16 06:33:05 -0800</bug_when>
    <thetext>Summary

@scope with a custom-element root works in older Safari/WebKit, but fails in newer WebKit builds. Equivalent non-scoped selectors still work.

Minimal repro

Save as scope-custom-root-repro.html and open in browser.

&lt;!doctype html&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;
&lt;x-shell id=&quot;control-root&quot;&gt;&lt;span class=&quot;child&quot;&gt;control child&lt;/span&gt;&lt;/x-shell&gt;
&lt;x-shell id=&quot;scoped-root&quot;&gt;&lt;span class=&quot;child&quot;&gt;scoped child&lt;/span&gt;&lt;/x-shell&gt;

&lt;style&gt;
  x-shell { display:block; margin:8px 0; }
  
  #control-root { color: rgb(0, 128, 0); }
  #control-root .child { color: rgb(0, 128, 0); }
  
  @scope (#scoped-root) {
    :scope { color: rgb(255, 0, 0); }
    .child { color: rgb(255, 0, 0); }
  }
&lt;/style&gt;

&lt;script&gt;
  customElements.define(&apos;x-shell&apos;, class extends HTMLElement {
    constructor() {
      super();
      const r = this.attachShadow({ mode: &apos;open&apos; });
      r.innerHTML = &apos;&lt;slot&gt;&lt;/slot&gt;&apos;;
    }
  });
&lt;/script&gt;

Steps to reproduce

1. Open file in Safari/WebKit
2. Check computed color of #scoped-root and #scoped-root .child

Expected behavior

- #scoped-root and .child are red

Actual behavior in newer WebKit

- #scoped-root and .child remain black (scoped block not applied)

Control

- #control-root rules apply correctly (green), showing regular selector path is fine

Interoperability / version notes

- Chromium: works
- WebKit 17.4 (Playwright WebKit build): works
- WebKit 26.0 (Playwright WebKit build): fails
- This suggests a regression in newer WebKit</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2182070</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-02-16 07:41:24 -0800</bug_when>
    <thetext>&lt;rdar://problem/170474720&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2182110</commentid>
    <comment_count>2</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-16 10:00:36 -0800</bug_when>
    <thetext>*** Safari Technology Preview 237 ***

scope child &lt;- it is not red.

*** Chrome Canary 147 ***

scope child &lt;- it is red.

*** Firefox Nightly 149 ***

scope child &lt;- it is red.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2204437</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-04-25 06:31:37 -0700</bug_when>
    <thetext>WebKit ToT (312015@main) matches Chrome Canary 149.0.7809.0 (Official Build) canary (arm64)  and have `scope child` as red. So it is fixed now on ToT but still broken on Safari Technology Preview 242.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2208608</commentid>
    <comment_count>4</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2026-05-07 09:14:32 -0700</bug_when>
    <thetext>

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

    </bug>

</bugzilla>