<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>17924</bug_id>
          
          <creation_ts>2012-07-18 07:17:58 +0000</creation_ts>
          <short_desc>Setting innerHTML on an SVG element will parse into HTML elements. Since innerHTML is available on Element now, we should check if the context element is an SVG element (or MathML element) other than foreignObject (etc) and use the foreign lands insertion</short_desc>
          <delta_ts>2013-06-06 19:56:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#parsing-html-fragments</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>blocker</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>adrianba</cc>
    
    <cc>annevk</cc>
    
    <cc>cam</cc>
    
    <cc>eseidel</cc>
    
    <cc>ian</cc>
    
    <cc>james</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>poccil</cc>
    
    <cc>rafaelw</cc>
    
    <cc>travil</cc>
    
    <cc>w3c</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>70309</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2012-07-18 07:17:58 +0000</bug_when>
    <thetext>This was was cloned from bug 16635 as part of operation convergence.
Originally filed: 2012-04-04 10:58:00 +0000

================================================================================
 #0   contributor@whatwg.org                          2012-04-04 10:58:52 +0000 
--------------------------------------------------------------------------------
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html
Multipage: http://www.whatwg.org/C#parsing-html-fragments
Complete: http://www.whatwg.org/c#parsing-html-fragments

Comment:
Setting innerHTML on an SVG element will parse into HTML elements. Since
innerHTML is available on Element now, we should check if the context element
is an SVG element (or MathML element) other than foreignObject (etc) and use
the foreign lands insertion mode.

Posted from: 88.131.66.80 by simonp@opera.com
User agent: Opera/9.80 (Macintosh; Intel Mac OS X 10.7.2; U; en) Presto/2.10.229 Version/11.62
================================================================================
 #1   Cameron McCormack                               2012-04-04 11:19:56 +0000 
--------------------------------------------------------------------------------
That&apos;d be awesome if it could work, yeah.
================================================================================
 #2   Simon Pieters                                   2012-04-05 07:11:43 +0000 
--------------------------------------------------------------------------------
Cases to consider:

context element is one of the following

&lt;svg&gt;&lt;g/&gt;&lt;foreignobject/&gt;&lt;desc/&gt;&lt;title/&gt;&lt;/svg&gt;
&lt;math&gt;&lt;mrow/&gt;&lt;mi/&gt;&lt;mo/&gt;&lt;mn/&gt;&lt;ms/&gt;&lt;mtext/&gt;&lt;annotation-xml/&gt;&lt;annotatoin-xml encoding=text/html /&gt;&lt;/math&gt;

markup is one of the following

&quot;&lt;b&gt;x&quot;
&quot;&lt;svg&gt;&quot;
&quot;&lt;p&gt;&quot;
&quot;&lt;/svg&gt;&quot;
&quot;&lt;mglyph&gt;&quot;
&quot;&lt;malignmark&gt;&quot;
...
================================================================================
 #3   Simon Pieters                                   2012-04-05 07:38:07 +0000 
--------------------------------------------------------------------------------
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1451
================================================================================
 #4   Simon Pieters                                   2012-04-05 12:53:12 +0000 
--------------------------------------------------------------------------------
Desired outcome, I think (using html5lib test syntax to indicate namespace):

&lt;math math&gt;.innerHTML = &apos;&lt;b&gt;x&apos;;
| &lt;math math&gt;
|   &lt;b&gt;
|     &quot;x&quot;

&lt;math math&gt;.innerHTML = &apos;&lt;foo&gt;&lt;b&gt;x&apos;;
| &lt;math math&gt;
|   &lt;math foo&gt;
| &lt;b&gt;
|   &quot;x&quot;

i.e. the &quot;break out&quot; step needs to be changed to not pop the current element if that&apos;s an html element (fragment case), but should otherwise work like normal.

&lt;math mi&gt;.innerHTML = &apos;&lt;b&gt;x&apos;;
| &lt;math mi&gt;
|   &lt;b&gt;
|     &quot;x&quot;

&lt;math mi&gt;.innerHTML = &apos;&lt;foo&gt;&lt;b&gt;x&apos;;
| &lt;math mi&gt;
|   &lt;foo&gt;
|     &lt;b&gt;
|       &quot;x&quot;

&lt;math mi&gt;.innerHTML = &apos;&lt;mglyph&gt;&apos;;
| &lt;math mi&gt;
|   &lt;math mglyph&gt;

&lt;math mi&gt;.innerHTML = &apos;&lt;malignmark&gt;&apos;;
| &lt;math mi&gt;
|   &lt;math malignmark&gt;

&lt;math mi&gt;.innerHTML = &apos;&lt;svg&gt;&apos;;
| &lt;math mi&gt;
|   &lt;svg svg&gt;

&lt;math annotation-xml&gt;.innerHTML = &apos;&lt;svg&gt;&apos;;
| &lt;math annotation-xml&gt;
|   &lt;svg svg&gt;

&lt;math annotation-xml&gt;.innerHTML = &apos;&lt;foo&gt;&apos;;
| &lt;math annotation-xml&gt;
|   &lt;math foo&gt;

&lt;math annotation-xml encoding=&quot;text/html&quot;&gt;.innerHTML = &apos;&lt;foo&gt;&apos;;
| &lt;math annotation-xml&gt;
|   encoding=&quot;text/html&quot;
|   &lt;foo&gt;
================================================================================
 #5   Simon Pieters                                   2012-04-05 12:53:13 +0000 
--------------------------------------------------------------------------------
Desired outcome, I think (using html5lib test syntax to indicate namespace):

&lt;math math&gt;.innerHTML = &apos;&lt;b&gt;x&apos;;
| &lt;math math&gt;
|   &lt;b&gt;
|     &quot;x&quot;

&lt;math math&gt;.innerHTML = &apos;&lt;foo&gt;&lt;b&gt;x&apos;;
| &lt;math math&gt;
|   &lt;math foo&gt;
| &lt;b&gt;
|   &quot;x&quot;

i.e. the &quot;break out&quot; step needs to be changed to not pop the current element if that&apos;s an html element (fragment case), but should otherwise work like normal.

&lt;math mi&gt;.innerHTML = &apos;&lt;b&gt;x&apos;;
| &lt;math mi&gt;
|   &lt;b&gt;
|     &quot;x&quot;

&lt;math mi&gt;.innerHTML = &apos;&lt;foo&gt;&lt;b&gt;x&apos;;
| &lt;math mi&gt;
|   &lt;foo&gt;
|     &lt;b&gt;
|       &quot;x&quot;

&lt;math mi&gt;.innerHTML = &apos;&lt;mglyph&gt;&apos;;
| &lt;math mi&gt;
|   &lt;math mglyph&gt;

&lt;math mi&gt;.innerHTML = &apos;&lt;malignmark&gt;&apos;;
| &lt;math mi&gt;
|   &lt;math malignmark&gt;

&lt;math mi&gt;.innerHTML = &apos;&lt;svg&gt;&apos;;
| &lt;math mi&gt;
|   &lt;svg svg&gt;

&lt;math annotation-xml&gt;.innerHTML = &apos;&lt;svg&gt;&apos;;
| &lt;math annotation-xml&gt;
|   &lt;svg svg&gt;

&lt;math annotation-xml&gt;.innerHTML = &apos;&lt;foo&gt;&apos;;
| &lt;math annotation-xml&gt;
|   &lt;math foo&gt;

&lt;math annotation-xml encoding=&quot;text/html&quot;&gt;.innerHTML = &apos;&lt;foo&gt;&apos;;
| &lt;math annotation-xml&gt;
|   encoding=&quot;text/html&quot;
|   &lt;foo&gt;
================================================================================
 #6   Simon Pieters                                   2012-04-05 12:55:59 +0000 
--------------------------------------------------------------------------------
(In reply to comment #4)
&gt; &lt;math math&gt;.innerHTML = &apos;&lt;foo&gt;&lt;b&gt;x&apos;;
&gt; | &lt;math math&gt;
&gt; |   &lt;math foo&gt;
&gt; | &lt;b&gt;
&gt; |   &quot;x&quot;

Oops. I meant this:

&lt;math math&gt;.innerHTML = &apos;&lt;foo&gt;&lt;b&gt;x&apos;;
| &lt;math math&gt;
|   &lt;math foo&gt;
|   &lt;b&gt;
|     &quot;x&quot;
================================================================================</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72735</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-08-24 22:17:19 +0000</bug_when>
    <thetext>Proposal:

- In the tree construction dispatch algorithm, change the references to &quot;current node&quot; to be references to a concept that is equal to current node like today except when the current node is the only element in the stack and we&apos;re in a fragment parsing scenario (&quot;If the parser was originally created for the HTML fragment parsing algorithm&quot;), in which case it instead is equal to the context node (fragment case).
- In the foreign content rules, in the handling of &quot;b&quot; start tags etc, skip the paragraph that does the popping if the current node is the only node in the stack (fragment case).
- In the foreign content rules, in the handling of &quot;b&quot; start tags etc, if the current node is the only node in the stack, instead of reprocessing the token, specifically reprocess it in the &quot;in body&quot; mode (fragment case).
- In the foreign content rules, &quot;any other end tag&quot;, at the start of the loop step, abort if /node/ is the only node in the stack (fragment case). (This is needed to avoid problems with &lt;svg&gt;.innerHTML = &quot;&lt;/html&gt;&quot;.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77469</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-10-30 22:32:41 +0000</bug_when>
    <thetext>Anyone object to the parser changes in comment 1?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82416</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-01-31 17:51:44 +0000</bug_when>
    <thetext>Last chance to object to this HTML parser change before I go ahead and do it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82430</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Barth">w3c</who>
    <bug_when>2013-01-31 20:14:21 +0000</bug_when>
    <thetext>I haven&apos;t reviewed the details, but the general approach sounds reasonable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82480</commentid>
    <comment_count>5</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2013-02-01 19:19:35 +0000</bug_when>
    <thetext>This sounds reasonable to me too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84950</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-03-25 22:12:32 +0000</bug_when>
    <thetext>Let me know if this breaks anything...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84951</commentid>
    <comment_count>7</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-03-25 22:29:57 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7768.
Check-in comment: Parser change: Handle fragment case for non-HTML nodes. This _should_ have no effect on any other case, so please do let me know if this breaks any tests!
http://html5.org/tools/web-apps-tracker?from=7767&amp;to=7768</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85169</commentid>
    <comment_count>8</comment_count>
    <who name="Peter Occil">poccil</who>
    <bug_when>2013-03-30 08:32:14 +0000</bug_when>
    <thetext>The change fails on the following case (found in parsing/test_tests9.html of the approved test cases):

&lt;!DOCTYPE html&gt;&lt;math&gt;&lt;annotation-xml&gt;&lt;svg&gt;&lt;u&gt;

Note that this isn&apos;t a fragment case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86249</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-04-15 22:42:46 +0000</bug_when>
    <thetext>What&apos;s the output with that case now?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86261</commentid>
    <comment_count>10</comment_count>
    <who name="Peter Occil">poccil</who>
    <bug_when>2013-04-16 00:39:44 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; What&apos;s the output with that case now?

With my HTML parser, before I fixed the issue by checking for the fragment case explicitly, I had the following output:

| &lt;!DOCTYPE html&gt;
| &lt;html&gt;
|   &lt;head&gt;
|   &lt;body&gt;
|     &lt;math math&gt;
|       &lt;math annotation-xml&gt;
|         &lt;svg svg&gt;
|           &lt;u&gt;

The correct output according to that test is:

| &lt;!DOCTYPE html&gt;
| &lt;html&gt;
|   &lt;head&gt;
|   &lt;body&gt;
|     &lt;math math&gt;
|       &lt;math annotation-xml&gt;
|         &lt;svg svg&gt;
|     &lt;u&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86904</commentid>
    <comment_count>11</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-04-26 22:30:25 +0000</bug_when>
    <thetext>Oh, I see. I screwed up when using the &quot;in scope&quot; thing in the text I added to handle &lt;u&gt; and company in foreign content.

I think I meant to check if the stack of open elements has one of the listed element in it at all, not just if it&apos;s in scope. So I just need to strike &quot;in scope&quot;.

Anyone disagree?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88840</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-06-06 19:54:30 +0000</bug_when>
    <thetext>I just turned this quirk off entirely in innerHTML.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88842</commentid>
    <comment_count>13</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-06-06 19:56:40 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r7918.
Check-in comment: Turn off a quirk in foreign lands when doing innerHTML parsing
http://html5.org/tools/web-apps-tracker?from=7917&amp;to=7918</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>