<?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>26804</bug_id>
          
          <creation_ts>2014-09-15 10:18:25 +0000</creation_ts>
          <short_desc>innerHTML on elements that aren&apos;t HTML, SVG, or MathML creates elements not in those namespaces</short_desc>
          <delta_ts>2014-12-01 18:31:39 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM Parsing and Serialization</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3177</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Henri Sivonen">hsivonen</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>dtrebbien</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>111512</commentid>
    <comment_count>0</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-09-15 10:18:25 +0000</bug_when>
    <thetext>Condsider the Blink behavior for http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3177

The element with the local name &quot;bar&quot; ends up in the &quot;bogus&quot; namespace. Surprisingly, this is correct per spec. (The &quot;div&quot; ending up in the HTML namespace is no longer correct per spec; Blink isn&apos;t up-to-date with the spec.)

Hixie said on IRC that this is unintentional.

Please, either make fragment parsing with a non-HTML/SVG/MathML context work like with non-special HTML context or explicitly alert the reader of the spec of the surprising consequence that the fragment parsing algorithm can produces nodes that aren&apos;t HTML/SVG/MathML.

(FWIW, the parser used in Validator.nu and in Gecko has been written with the assumption that all nodes ever created by the algorithm are in the HTML/SVG/MathML namespaces.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112088</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-24 17:25:15 +0000</bug_when>
    <thetext>So, looking at this more closely, I don&apos;t really understand why this wouldn&apos;t be expected. Why is it different than if the namespace was SVG? The part of this that is surprising is the part where the author introduces a non-standard namespace into the document, IMHO, not the part where the parser tries its best to muddle along given that environment. What namespace would you want the spec to use, and why?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112235</commentid>
    <comment_count>2</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-09-26 05:18:21 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #1)
&gt; So, looking at this more closely, I don&apos;t really understand why this
&gt; wouldn&apos;t be expected.

Well, I was quite surprised to learn that this is happening, because the algorithm and the history of how it was developed made it look like it dealt with three element namespaces.

&gt; Why is it different than if the namespace was SVG?

It&apos;s not any of the three namespaces the algorithm was *designed* for.

&gt; The
&gt; part of this that is surprising is the part where the author introduces a
&gt; non-standard namespace into the document, IMHO, not the part where the
&gt; parser tries its best to muddle along given that environment. What namespace
&gt; would you want the spec to use, and why?

I want either:
 1) The fragment parsing spec to carry an informative warning to implementors that its output isn&apos;t limited to the three element namespaces. (I have written code with the assumption that there are only three namespaces. Specifically, with node constructors that don&apos;t pass the namespace but have distinct signatures for the three namespaces.)
OR
 2) The fragment parsing algorithm to put elements in the HTML namespace when the context isn&apos;t in any of the three element namespaces that the algorithm cares about.

#1 is less work for Blink. #2 is less work for me.

#1 arguably makes more sense for authors, but it also opens up more opportunity for weirdness/bugs that neither you nor I have thought about yet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112286</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-26 18:02:29 +0000</bug_when>
    <thetext>Ok, those two options seem reasonable.

One other problem with #2 is that it makes it harder to shim the parser when we add new namespaces in the future. For example, say we want to support XSLFO natively. As specced today, this would only require minimal changes (a new element to trigger the foreign lands), and innerHTML would already Just Work, so shims could do it that way. Of course the counter-argument to this is that the odds of us introducing a new namespace to the Web are essentially zero.

Another argument against #2 is that it is spec churn. The counter to that is that there&apos;s zero content depending on this, probably, since it only comes up when you do innerHTML on namespaced content.

An argument against all of this is why on earth are we allowing an API like innerHTML to be applied to non-HTML content. The name doesn&apos;t match, plus, it&apos;s a horrific API with serious security issues almost as bad as document.write().

Safari doesn&apos;t support innerHTML here. This suggests option #3, that we not make innerHTML apply to elements that aren&apos;t in the three blessed namespaces. (The reason the spec handles this case as it does is because when it was written, I didn&apos;t expect us to move innerHTML to Element, so I never even thought about this issue.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112442</commentid>
    <comment_count>4</comment_count>
    <who name="Henri Sivonen">hsivonen</who>
    <bug_when>2014-09-30 06:24:57 +0000</bug_when>
    <thetext>(In reply to Ian &apos;Hixie&apos; Hickson from comment #3)
&gt; Safari doesn&apos;t support innerHTML here. This suggests option #3, that we not
&gt; make innerHTML apply to elements that aren&apos;t in the three blessed
&gt; namespaces. (The reason the spec handles this case as it does is because
&gt; when it was written, I didn&apos;t expect us to move innerHTML to Element, so I
&gt; never even thought about this issue.)

Wouldn&apos;t this cause even more churn considering that MathML elements don&apos;t have special DOM interfaces?

(Also, this option seems impolite to XML if anyone cares about that sort of thing anymore.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112447</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-09-30 07:58:38 +0000</bug_when>
    <thetext>We could make setting innerHTML throw (NotSupportedError or InvalidAccessError?) in HTML if the context node&apos;s namespace isn&apos;t one of the three, maybe?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112488</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-30 17:37:15 +0000</bug_when>
    <thetext>Seems weird to throw. Why have the API at all, if it just throws?

MathML does have a MathMLElement node:

   http://www.w3.org/TR/MathML2/appendixd.html

(Not quite sure what happened to that in MathML3; the intro says that it&apos;s in a &quot;separate document&quot; but doesn&apos;t seem to cite it.)

I don&apos;t see why it&apos;s impolite to XML. It seems more polite; impolite is the way we&apos;re stomping all over virgin namespaces adding global attributes and global APIs, IMHO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112521</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-10-01 10:57:34 +0000</bug_when>
    <thetext>Getting doesn&apos;t need to throw.

No browser implements MathML DOM interfaces AFAIK. Elements in the MathML namespace use Element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112670</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-10-03 21:51:03 +0000</bug_when>
    <thetext>Only one browser implements MathML at all, as far as I can tell.
So that doesn&apos;t say much.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112980</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-10-11 00:29:45 +0000</bug_when>
    <thetext>I think this should either be WONTFIX or reassigned to DOM to move innerHTML off Element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114690</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-11-07 21:46:05 +0000</bug_when>
    <thetext>Reassigning to DOM. IMHO innerHTML should just be on HTML elements. There&apos;s really no use case for it in the first place; it&apos;s a historical security-nightmare API that we should not encourage people to use.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114695</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-07 22:31:48 +0000</bug_when>
    <thetext>innerHTML is not defined in DOM.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>