<?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>249706</bug_id>
          
          <creation_ts>2022-12-21 03:45:07 -0800</creation_ts>
          <short_desc>The :checked pseudoselector for slotted content fails to repaint</short_desc>
          <delta_ts>2025-02-12 04:33:07 -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 15</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 11</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>https://codepen.io/istutto/pen/eYjmywN</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="Istvan Tutto">istvantutto</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>akeerthi</cc>
    
    <cc>elwinvaneede+bugzilla</cc>
    
    <cc>koivisto</cc>
    
    <cc>me</cc>
    
    <cc>ntim</cc>
    
    <cc>rniwa</cc>
    
    <cc>robin</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>vzemtsov</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1921034</commentid>
    <comment_count>0</comment_count>
    <who name="Istvan Tutto">istvantutto</who>
    <bug_when>2022-12-21 03:45:07 -0800</bug_when>
    <thetext>Hey team! 

I&apos;ve noticed that a checkbox element&apos;s :checked state styles will not be immediately applied when using a keyboard (SPACE) to select it and the styles are coming from within a ShadowDom&apos;s `::slotted(...)` selector. The styles will be applied after blur event only. The pointer interaction works as expected and all other major browsers handle the keyboard event as well.

Demonstration in link:
https://codepen.io/istutto/pen/eYjmywN

Note, that the above mentioned case will be resolved in Safari as well if the following empty rule as added into the light-DOM.
```css
input[type=checkbox]:checked {}
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922074</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-12-28 03:46:16 -0800</bug_when>
    <thetext>&lt;rdar://problem/103740708&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922220</commentid>
    <comment_count>2</comment_count>
      <attachid>464251</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-12-29 13:55:22 -0800</bug_when>
    <thetext>Created attachment 464251
Reduction</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922221</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-12-29 14:02:37 -0800</bug_when>
    <thetext>This seems to be a repaint bug. The attached test case uses Element::click() to mark the checkbox (instead of requiring keyboard input from user).

The checkbox turns blue as expected once you hover over the associated label, deactivate the window, etc...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922227</commentid>
    <comment_count>4</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2022-12-29 14:42:47 -0800</bug_when>
    <thetext>interestingly it works fine when no customElements are involved.

&lt;style&gt;
input[type=checkbox] {
  appearance: none;
  width: 50px;
  height: 50px;
}
input[type=checkbox]:checked {
  background-color: green;
}
&lt;/style&gt;
&lt;script&gt;
onload = () =&gt; {
  checkbox.focus();
  setTimeout(() =&gt; checkbox.click(), 0);
}
&lt;/script&gt;
&lt;input type=checkbox id=checkbox&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922229</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-12-29 14:44:12 -0800</bug_when>
    <thetext>I think something in the paint invalidation logic is failing to take slotted content into account.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1922231</commentid>
    <comment_count>6</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2022-12-29 14:55:16 -0800</bug_when>
    <thetext>The render tree does not seem to get notified about the style change :|</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2035753</commentid>
    <comment_count>7</comment_count>
    <who name="Istvan Tutto">istvantutto</who>
    <bug_when>2024-05-16 04:58:27 -0700</bug_when>
    <thetext>Hello, 
A kindly reminder that this bug has been reported around 18 months ago and the bug still exists in the latest versions as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2083315</commentid>
    <comment_count>8</comment_count>
    <who name="">vzemtsov</who>
    <bug_when>2024-12-20 08:30:50 -0800</bug_when>
    <thetext>Hi, I am also experiencing this issue with the same prerequisites: custom styles, shadow root.
I try to change the checkbox state by calling `.click()` on it, and the state changes, but the UI is not refreshed. The same happens if I use `.checked` property programmatically: state changes, but the visual appearance does not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2087043</commentid>
    <comment_count>9</comment_count>
    <who name="">me</who>
    <bug_when>2025-01-14 06:45:02 -0800</bug_when>
    <thetext>(In reply to vzemtsov from comment #8)
&gt; Hi, I am also experiencing this issue with the same prerequisites: custom
&gt; styles, shadow root.
&gt; I try to change the checkbox state by calling `.click()` on it, and the
&gt; state changes, but the UI is not refreshed. The same happens if I use
&gt; `.checked` property programmatically: state changes, but the visual
&gt; appearance does not.

I can confirm the exact behaviour, as described. Would be nice to get this fixed at some point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2094116</commentid>
    <comment_count>10</comment_count>
    <who name="Elwin van Eede">elwinvaneede+bugzilla</who>
    <bug_when>2025-02-12 04:33:07 -0800</bug_when>
    <thetext>I&apos;m also running into this issues with slotted radio buttons (`&lt;input type=&quot;radio&quot;&gt;`), see this minimal reproduction: https://codepen.io/elwinvaneede/pen/QwWWYLM.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>464251</attachid>
            <date>2022-12-29 13:55:22 -0800</date>
            <delta_ts>2022-12-29 13:55:22 -0800</delta_ts>
            <desc>Reduction</desc>
            <filename>bug249706.html</filename>
            <type>text/html</type>
            <size>1058</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxzdHlsZT4KCi8qIFVuY29tbWVudCB0aGUgZm9sbG93aW5nIHRvIHJl
c29sdmUgdGhlIGJ1ZyBpbiBTYWZhcmkuCmlucHV0W3R5cGU9Y2hlY2tib3hdOmNoZWNrZWQge30g
Ki8KCjwvc3R5bGU+CjxzY3JpcHQ+CmNsYXNzIElucHV0V3JhcHBlckVsZW1lbnQgZXh0ZW5kcyBI
VE1MRWxlbWVudCB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5hdHRh
Y2hTaGFkb3coe21vZGU6ICdvcGVuJ30pLmlubmVySFRNTCA9IGAKICAgIDxzdHlsZT4KICAgICAg
OjpzbG90dGVkKGlucHV0W3R5cGU9Y2hlY2tib3hdKSB7CiAgICAgICAgYXBwZWFyYW5jZTpub25l
OwogICAgICAgIHdpZHRoOiAxcmVtOwogICAgICAgIGhlaWdodDogMXJlbTsKICAgICAgICBib3Jk
ZXItcmFkaXVzOiAycHg7CiAgICAgICAgYm9yZGVyOiAycHggc29saWQgZ3JleTsKICAgICAgICBt
YXJnaW4tYm90dG9tOiAtLjEyNXJlbTsKICAgICAgfQogICAgICA6OnNsb3R0ZWQoaW5wdXRbdHlw
ZT1jaGVja2JveF06Y2hlY2tlZCkgewogICAgICAgIGJvcmRlci1jb2xvcjogYmx1ZTsKICAgICAg
ICBiYWNrZ3JvdW5kLWNvbG9yOiBibHVlOwogICAgICB9CiAgICA8L3N0eWxlPgogICAgPHNsb3Q+
PC9zbG90PgogICAgYAogIH0KfQoKY3VzdG9tRWxlbWVudHMuZGVmaW5lKCdpbnB1dC13cmFwcGVy
JywgSW5wdXRXcmFwcGVyRWxlbWVudCk7Cm9ubG9hZCA9ICgpID0+IHsKICBjaGVja2JveC5mb2N1
cygpOwogIHNldFRpbWVvdXQoKCkgPT4gY2hlY2tib3guY2xpY2soKSwgMCk7Cn0KPC9zY3JpcHQ+
CjxpbnB1dC13cmFwcGVyPgogIDxpbnB1dCB0eXBlPWNoZWNrYm94IGlkPWNoZWNrYm94IG9uY2hh
bmdlPSdyZXN1bHQudGV4dENvbnRlbnQ9dGhpcy5jaGVja2VkID8gImNoZWNrZWQiIDogInVuY2hl
Y2tlZCInIGF1dG9mb2N1cz4KICA8bGFiZWwgZm9yPWNoZWNrYm94PlRoaXMgY2hlY2tib3ggc2hv
dWxkIGJlIGJsdWU8bGFiZWw+CjwvaW5wdXQtd3JhcHBlcj4KPGRpdj5DaGVja2JveCBzdGF0ZTog
PHNwYW4gaWQ9InJlc3VsdCI+PC9zcGFuPjwvZGl2Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>