<?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>137501</bug_id>
          
          <creation_ts>2014-10-07 15:20:01 -0700</creation_ts>
          <short_desc>HTML foster-parenting algorithm no longer requires foster parents to be elements</short_desc>
          <delta_ts>2022-08-16 21:53: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>DOM</component>
          <version>528+ (Nightly build)</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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Klein">adamk</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1040143</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2014-10-07 15:20:01 -0700</bug_when>
    <thetext>Consider the following HTML page:

&lt;body&gt;
  &lt;table&gt;
    &lt;script&gt;
      var fragment = document.createDocumentFragment();
      fragment.appendChild(document.querySelector(&apos;table&apos;));
    &lt;/script&gt;
    &lt;div&gt;&lt;/div&gt;
  &lt;/table&gt;
&lt;/body&gt;

According to the current HTML spec, this should end up foster-parenting the &lt;div&gt; into the document fragment (since it&apos;s the &lt;table&gt;&apos;s parent when the foster-parenting algorithm runs). But the spec used to require foster parents to be elements, and so WebKit and Blink put the div, instead, as a child of &lt;body&gt;.

In Blink, I&apos;m about to land https://codereview.chromium.org/640433002, which changes that behavior to match the spec (it was changed to support the &lt;template&gt; element, according to Hixie on #whatwg). It&apos;d be nice to keep us compatible, so if you think this is the wrong way to go, please let me know. Alternatively, it should be easy to update your parser to match the spec (see step 2 of https://html.spec.whatwg.org/#appropriate-place-for-inserting-a-node).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1890156</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-08-09 17:11:07 -0700</bug_when>
    <thetext>Safari pass all WPT tests related to foster parenting:

https://wpt.fyi/results/html/syntax/parsing/template/additions-to-foster-parenting?label=master&amp;label=experimental&amp;aligned&amp;view=subtest&amp;q=foster%20parent

rniwa@webkit.org - Is this still needed? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891198</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-08-13 23:08:49 -0700</bug_when>
    <thetext>Yes, WebKit&apos;s behavior matches that of Gecko, and differs from that of Blink. It&apos;s probably better to align ourselves with the spec &amp; Blink at this point.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891200</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-08-13 23:39:41 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/3295</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891859</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-08-16 21:52:00 -0700</bug_when>
    <thetext>Committed 253504@main (3363325609a1): &lt;https://commits.webkit.org/253504@main&gt;

Reviewed commits have been landed. Closing PR #3295 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891860</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-08-16 21:53:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/98764301&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>