<?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>290396</bug_id>
          
          <creation_ts>2025-03-25 10:05:46 -0700</creation_ts>
          <short_desc>Form controls inside a declarative shadow DOM erroneously get associated with form element in an outer tree</short_desc>
          <delta_ts>2025-03-26 08:21:15 -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>Forms</component>
          <version>Safari 18</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HTML5, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>148695</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Konnor Rogers">konnor5456</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>cdumez</cc>
    
    <cc>nathan</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2105904</commentid>
    <comment_count>0</comment_count>
    <who name="Konnor Rogers">konnor5456</who>
    <bug_when>2025-03-25 10:05:46 -0700</bug_when>
    <thetext>## Explanation

In Desktop Safari 17.5 and 18.3.1 and iOS Safari 18.3.2 (only tested versions so far) a form control rendered inside a declarative shadow DOM leak into the host element&apos;s form. This does not happen in Firefox 136 or Chrome 134.

Essentially when you have the following:

&lt;form&gt;
  &lt;x-element&gt;
    &lt;template shadowrootmode=&quot;open&quot;&gt;
      &lt;input name=&quot;foo&quot; value=&quot;bar&quot;&gt;
    &lt;/template&gt;
  &lt;/x-element&gt;
&lt;/form&gt;

the FormData you will get the following:

formData.getAll(&quot;foo&quot;) // =&gt; [&quot;bar&quot;]

only in Safari. In Firefox and Chrome you will get an empty array. In addition, doing `form.elements` returns form controls from the shadow dom in Safari. This does not happen when the shadow dom is client side rendered *only* when its rendered via Declarative Shadow DOM. This feels like unintended and unexpected behavior.

https://codepen.io/paramagicdev/pen/gbOjxJy

^ reproduction</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106050</commentid>
    <comment_count>1</comment_count>
      <attachid>474714</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2025-03-25 18:50:50 -0700</bug_when>
    <thetext>Created attachment 474714
Reduction</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106051</commentid>
    <comment_count>2</comment_count>
      <attachid>474715</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2025-03-25 19:15:39 -0700</bug_when>
    <thetext>Created attachment 474715
More test cases</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106083</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2025-03-25 23:55:58 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/43034</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106086</commentid>
    <comment_count>4</comment_count>
    <who name="Konnor Rogers">konnor5456</who>
    <bug_when>2025-03-26 00:32:26 -0700</bug_when>
    <thetext>As an additional note, the same mechanism seems to affect button submissions as well:

https://codepen.io/paramagicdev/pen/bNGjmZg

buttons clicked inside a declarative shadow dom cause a form in an outer tree to submit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106138</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-03-26 08:20:15 -0700</bug_when>
    <thetext>Committed 292703@main (e657338dfd41): &lt;https://commits.webkit.org/292703@main&gt;

Reviewed commits have been landed. Closing PR #43034 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2106139</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-03-26 08:21:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/147932589&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>474714</attachid>
            <date>2025-03-25 18:50:50 -0700</date>
            <delta_ts>2025-03-25 18:50:50 -0700</delta_ts>
            <desc>Reduction</desc>
            <filename>bug290396.html</filename>
            <type>text/html</type>
            <size>224</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cjxmb3JtPgo8c29tZS1lbGVtZW50Pgo8dGVtcGxhdGUgc2hhZG93cm9v
dG1vZGU9ImNsb3NlZCI+CjxpbnB1dCBuYW1lPSJlbWFpbCIgdmFsdWU9ImJsYWgiPgo8L3RlbXBs
YXRlPgo8L3NvbWUtZWxlbWVudD4KPC9mb3JtPgo8c2NyaXB0Pgpkb2N1bWVudC53cml0ZShkb2N1
bWVudC5mb3Jtc1swXVsnZW1haWwnXSA/ICdGQUlMJyA6ICdQQVNTJyk7Cjwvc2NyaXB0Pgo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>474715</attachid>
            <date>2025-03-25 19:15:39 -0700</date>
            <delta_ts>2025-03-25 19:15:39 -0700</delta_ts>
            <desc>More test cases</desc>
            <filename>bug290396.html</filename>
            <type>text/html</type>
            <size>758</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cjxmb3JtPgo8c29tZS1lbGVtZW50Pjx0ZW1wbGF0ZSBzaGFkb3dyb290
bW9kZT0ib3BlbiI+PGlucHV0IG5hbWU9ImVtYWlsIj48Zm9ybT48aW5wdXQgbmFtZT0ibmlja25h
bWUiPjwvZm9ybT48L3RlbXBsYXRlPjwvc29tZS1lbGVtZW50Pgo8aW5wdXQgbmFtZT0ibmFtZSI+
CjwvZm9ybT4KPHNjcmlwdD4KZG9jdW1lbnQud3JpdGUoZG9jdW1lbnQuZm9ybXNbMF1bJ2VtYWls
J10gPyAnRkFJTCcgOiAnUEFTUycpOwpkb2N1bWVudC53cml0ZSgnPGJyPicpOwpkb2N1bWVudC53
cml0ZShkb2N1bWVudC5mb3Jtc1swXVsnbmlja25hbWUnXSA/ICdGQUlMJyA6ICdQQVNTJyk7CmRv
Y3VtZW50LndyaXRlKCc8YnI+Jyk7CmRvY3VtZW50LndyaXRlKGRvY3VtZW50LmZvcm1zWzBdWydu
YW1lJ10gPyAnUEFTUycgOiAnRkFJTCcpOwpkb2N1bWVudC53cml0ZSgnPGJyPicpOwpkb2N1bWVu
dC53cml0ZShkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCdzb21lLWVsZW1lbnQnKS5zaGFkb3dSb290
LmlubmVySFRNTCA9PSAnPGlucHV0IG5hbWU9ImVtYWlsIj48Zm9ybT48aW5wdXQgbmFtZT0ibmlj
a25hbWUiPjwvZm9ybT4nID8gJ1BBU1MnIDogJ0ZBSUwnKTsKZG9jdW1lbnQud3JpdGUoJzxicj4n
KTsKZG9jdW1lbnQud3JpdGUoZG9jdW1lbnQucXVlcnlTZWxlY3Rvcignc29tZS1lbGVtZW50Jyku
c2hhZG93Um9vdC5xdWVyeVNlbGVjdG9yKCdmb3JtJylbJ25pY2tuYW1lJ10gPyAnUEFTUycgOiAn
RkFJTCcpCjwvc2NyaXB0Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>