<?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>260772</bug_id>
          
          <creation_ts>2023-08-26 10:42:57 -0700</creation_ts>
          <short_desc>AX: Slot elements referenced with aria-labelledby not matching rendered output</short_desc>
          <delta_ts>2026-01-20 08:11:41 -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>Accessibility</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Carlos Lopez">clshortfuse</reporter>
          <assigned_to name="Tyler Wilcock">tyler_w</assigned_to>
          <cc>andresg_22</cc>
    
    <cc>cfleizach</cc>
    
    <cc>rniwa</cc>
    
    <cc>steverep+webkit</cc>
    
    <cc>tyler_w</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1973783</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Lopez">clshortfuse</who>
    <bug_when>2023-08-26 10:42:57 -0700</bug_when>
    <thetext>When using fallback content for slots, Safari appears to use `innerText` slot.
When fallback nodes are used, these always override the slotted content.
Hidden nodes are also, incorrectly, part of the AXLabel.

Testcase:

&lt;body&gt;
  &lt;script&gt;
    function componentFromFragment(name, fragment) {
      return customElements.define(name, class extends HTMLElement {
        constructor() {
        super();
        this.attachShadow({ mode: &quot;open&quot;, delegatesFocus: true });
        this.shadowRoot.append(document.createRange().createContextualFragment(fragment).cloneNode(true));
      }
      })
    }
    componentFromFragment(&quot;x-button&quot;, `
          &lt;input aria-labelledby=slot type=button&gt;&lt;slot id=slot&gt;&lt;/slot&gt;
    `);
    componentFromFragment(&quot;x-button-fallback&quot;, `
       &lt;input aria-labelledby=slot type=button&gt;&lt;slot id=slot&gt;&lt;span&gt;Fallback&lt;/span&gt;&lt;/slot&gt;
    `);
    componentFromFragment(&quot;x-button-hidden&quot;, `
          &lt;input aria-labelledby=slot type=button&gt;&lt;slot id=slot&gt;&lt;span style=&quot;display:none&quot;&gt;Hidden&lt;/span&gt;&lt;/slot&gt;
    `);
  &lt;/script&gt;
  &lt;x-button&gt;Slotted&lt;/x-button&gt;
  &lt;x-button&gt;Slotted&lt;span style=&quot;display:none&quot;&gt;Hidden&lt;/span&gt;&lt;/x-button&gt;
  &lt;x-button-fallback&gt;Slotted&lt;/x-button-fallback&gt;
  &lt;x-button-fallback&gt;&lt;/x-button-fallback&gt;
  &lt;x-button-hidden&gt;Slotted&lt;/x-button-hidden&gt;
  &lt;x-button-hidden&gt;&lt;/x-button-hidden&gt;
  
&lt;/body&gt;



expected:  [&apos;Slotted&apos;, &apos;Slotted&apos;,        &apos;Slotted&apos;,  &apos;Fallback&apos;, &apos;Slotted&apos;, &apos;&apos;      ]
actual:    [&apos;Slotted&apos;, &apos;Slotted Hidden&apos;, &apos;Fallback&apos;, &apos;Fallback&apos;, &apos;Hidden&apos;,  &apos;Hidden&apos;]

CodePen: https://codepen.io/shortfuse/pen/yLGYWwp

Related: https://bugs.webkit.org/show_bug.cgi?id=254934

This is working properly in Chrome and Firefox (nightly/116)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1973784</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-08-26 10:43:04 -0700</bug_when>
    <thetext>&lt;rdar://problem/114500560&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1995955</commentid>
    <comment_count>2</comment_count>
    <who name="Steve Repsher">steverep+webkit</who>
    <bug_when>2023-11-30 12:23:52 -0800</bug_when>
    <thetext>Would this be fixed by https://bugs.webkit.org/show_bug.cgi?id=264410?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005348</commentid>
    <comment_count>3</comment_count>
    <who name="Carlos Lopez">clshortfuse</who>
    <bug_when>2024-01-16 12:49:43 -0800</bug_when>
    <thetext>It doesn&apos;t appear fixed in Safari 17.4 (and whatever nightly Playwright is using), so I&apos;m still relying on Mutation Observers on light DOM to work around.

You can observe for character data and rewrite the contents as aria-label and it will work:

https://github.com/clshortfuse/materialdesignweb/blob/76c686238605dba16f293063071fdeabad46be18/mixins/ControlMixin.js#L178

https://github.com/clshortfuse/materialdesignweb/blob/76c686238605dba16f293063071fdeabad46be18/mixins/ControlMixin.js#L100C4-L100C4

IIRC Safari 17.0 may have fixed using slotted content in general, but the issue of using fallback content in &lt;slot&gt; elements is still read as well as visually hidden nodes. The disconnect between what&apos;s rendered and the AXLabel still exists.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2173045</commentid>
    <comment_count>4</comment_count>
    <who name="Tyler Wilcock">tyler_w</who>
    <bug_when>2026-01-19 07:50:49 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/56835</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2173329</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-01-20 08:11:38 -0800</bug_when>
    <thetext>Committed 305882@main (dfd051863e02): &lt;https://commits.webkit.org/305882@main&gt;

Reviewed commits have been landed. Closing PR #56835 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>