<?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>276454</bug_id>
          
          <creation_ts>2024-07-10 16:24:47 -0700</creation_ts>
          <short_desc>Style doesn&apos;t update on :scope when an element is no longer a candidate for a CSS Scope rule</short_desc>
          <delta_ts>2025-08-06 15:40:57 -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 17</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>279225</dup_id>
          
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Zacky Ma">zacky</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>koivisto</cc>
    
    <cc>m_dubet</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2045643</commentid>
    <comment_count>0</comment_count>
    <who name="Zacky Ma">zacky</who>
    <bug_when>2024-07-10 16:24:47 -0700</bug_when>
    <thetext>When an element is changed and should no longer be selected by a scope rule, the styles defined in `:scope` persists.

For example, given the CSS code:

```
body {
  color: black;
}

@scope (.foo) {
  :scope {
    color: red;
  }

  :scope::after {
    content: &apos; more text&apos;;
  }

  span {
    color: green;
  }
}
```

and the HTML code:

```
&lt;body&gt;
  &lt;p class=&quot;foo&quot;&gt;Some &lt;span&gt;text&lt;/span&gt;&lt;/p&gt;
&lt;/body&gt;
```

When `foo` class is removed from `&lt;p&gt;`, the text color in `&lt;p&gt;` remains as red, instead of falling back to be the body color (black); &quot;more text&quot; remains instead of being removed. But the text color in `&lt;span&gt;` is correctly falling back to its parent&apos;s color, which is red.

Testing Codepen: https://codepen.io/marchbox/pen/JjQovBp</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2045644</commentid>
    <comment_count>1</comment_count>
    <who name="Zacky Ma">zacky</who>
    <bug_when>2024-07-10 16:26:01 -0700</bug_when>
    <thetext>Should&apos;ve also mentioned, forcing the element to be repainted, e.g. setting `&lt;p&gt;` with `visibility: hidden` then reset `visibility` does correct the styles.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2046845</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-07-17 16:31:24 -0700</bug_when>
    <thetext>&lt;rdar://problem/131962940&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2134774</commentid>
    <comment_count>3</comment_count>
    <who name="Matthieu Dubet">m_dubet</who>
    <bug_when>2025-08-06 15:40:57 -0700</bug_when>
    <thetext>

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

    </bug>

</bugzilla>