<?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>135698</bug_id>
          
          <creation_ts>2014-08-07 05:12:09 -0700</creation_ts>
          <short_desc>SVGElement has no innerHTML property</short_desc>
          <delta_ts>2014-12-15 10:01:25 -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>SVG</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>136903</dup_id>
          
          <bug_file_loc></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="Ophir LOJKINE">pere.jobs</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>caitp</cc>
    
    <cc>damien.nozay</cc>
    
    <cc>galineau</cc>
    
    <cc>julien.sanchez</cc>
    
    <cc>krit</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1027467</commentid>
    <comment_count>0</comment_count>
    <who name="Ophir LOJKINE">pere.jobs</who>
    <bug_when>2014-08-07 05:12:09 -0700</bug_when>
    <thetext>In webkit, we can&apos;t access the innerHTML of an inline &lt;SVG&gt; element in an html document.

Steps to reproduce:
In the console, type

&apos;innerHTML&apos; in SVGSVGElement.prototype 

Results:
On Firefox and Chrome: true
On webkit: false</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027476</commentid>
    <comment_count>1</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2014-08-07 06:09:49 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; In webkit, we can&apos;t access the innerHTML of an inline &lt;SVG&gt; element in an html document.
&gt; 
&gt; Steps to reproduce:
&gt; In the console, type
&gt; 
&gt; &apos;innerHTML&apos; in SVGSVGElement.prototype 
&gt; 
&gt; Results:
&gt; On Firefox and Chrome: true

Is that the case for any SVG element in an HTML document? Even for &lt;rect&gt;, &lt;circle&gt;? Or just outer &lt;svg&gt; element?

&gt; On webkit: false</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027477</commentid>
    <comment_count>2</comment_count>
    <who name="Ophir LOJKINE">pere.jobs</who>
    <bug_when>2014-08-07 06:15:28 -0700</bug_when>
    <thetext>This is the case for all SVG elements (they all inherit from SVGElement, which doesn&apos;t have innerHTML)

&gt; &apos;innerHTML&apos; in SVGRectElement.prototype
&lt; false

&gt; &apos;innerHTML&apos; in SVGElement.prototype
&lt; false</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027478</commentid>
    <comment_count>3</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2014-08-07 06:27:02 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; This is the case for all SVG elements (they all inherit from SVGElement, which doesn&apos;t have innerHTML)

I was asking for Blink and Firefox. Does it work for all elements there, or just on the root &lt;svg&gt; element in HTML? (Beside all HTMLElements of course.)

&gt; 
&gt; &gt; &apos;innerHTML&apos; in SVGRectElement.prototype
&gt; &lt; false
&gt; 
&gt; &gt; &apos;innerHTML&apos; in SVGElement.prototype
&gt; &lt; false</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027479</commentid>
    <comment_count>4</comment_count>
    <who name="Ophir LOJKINE">pere.jobs</who>
    <bug_when>2014-08-07 06:30:55 -0700</bug_when>
    <thetext>&gt; I was asking for Blink and Firefox. Does it work for all elements there, or just on the root &lt;svg&gt; element in HTML? (Beside all HTMLElements of course.)

Yes, it works on every svg element on chrome and firefox (because all SVG elements inherit from SVGElement).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027480</commentid>
    <comment_count>5</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2014-08-07 06:33:30 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; &gt; I was asking for Blink and Firefox. Does it work for all elements there, or just on the root &lt;svg&gt; element in HTML? (Beside all HTMLElements of course.)
&gt; 
&gt; Yes, it works on every svg element on chrome and firefox

Ok. So they probably moved innerHTML on Element or added it to SVGElement. I assume innerHTML = &quot;&lt;rect&gt;&quot; still gives you an HTMLUnknownElement/HTMLElement on Blink and Firefox?


&gt; (because all SVG elements inherit from SVGElement).

Hehe, SVG elements always inherit from SVGElement and always did. The problem is/was that innerHTML is just defined for HTMLElement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027481</commentid>
    <comment_count>6</comment_count>
    <who name="Ophir LOJKINE">pere.jobs</who>
    <bug_when>2014-08-07 06:45:00 -0700</bug_when>
    <thetext>&gt; Ok. So they probably moved innerHTML on Element or added it to SVGElement. I assume innerHTML = &quot;&lt;rect&gt;&quot; still gives you an HTMLUnknownElement/HTMLElement on Blink and Firefox?

Yes. In the Firefox console:

&gt; div = document.createElement(&quot;div&quot;);
&gt; div.innerHTML = &quot;&lt;svg&gt;&lt;/svg&gt;&quot;;
&gt; div.firstChild.innerHTML = &quot;&lt;rect&gt;&quot;
&gt; div.firstChild.firstChild.__proto__
&lt; HTMLUnknownElementPrototype

(But IMO, it&apos;s a pitty. It makes it more complex to use templates to create SVG elements, for example).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027482</commentid>
    <comment_count>7</comment_count>
    <who name="Ophir LOJKINE">pere.jobs</who>
    <bug_when>2014-08-07 06:48:15 -0700</bug_when>
    <thetext>And firefox folks intend to change that behavior:
https://bugzilla.mozilla.org/show_bug.cgi?id=886390</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1027483</commentid>
    <comment_count>8</comment_count>
    <who name="Ophir LOJKINE">pere.jobs</who>
    <bug_when>2014-08-07 06:50:19 -0700</bug_when>
    <thetext>And in chrome, it works:
&lt; div = document.createElement(&quot;div&quot;);
&lt; div.innerHTML = &quot;&lt;svg&gt;&lt;/svg&gt;&quot;;
&lt; div.firstChild.innerHTML = &quot;&lt;rect&gt;&quot;
&lt; div.firstChild.firstChild.__proto__
&gt; SVGRectElement</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033960</commentid>
    <comment_count>9</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2014-09-08 14:42:46 -0700</bug_when>
    <thetext>The base interface for SVGElements does not have innerHTML exposed to scripts in its IDL --- in Blink and Gecko, innerHTML is exposed on the Element interface rather than HTMLElement interface, so they can share this common functionality.

It&apos;s probably not a terribly difficult patch to write to fix this, if I have some spare cycles in 2 weeks I&apos;ll be happy to take a shot at it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1033964</commentid>
    <comment_count>10</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2014-09-08 14:53:28 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; The base interface for SVGElements does not have innerHTML exposed to scripts in its IDL --- in Blink and Gecko, innerHTML is exposed on the Element interface rather than HTMLElement interface, so they can share this common functionality.
&gt; 
&gt; It&apos;s probably not a terribly difficult patch to write to fix this, if I have some spare cycles in 2 weeks I&apos;ll be happy to take a shot at it.

fwiw, the webkit treatment appears to be spec-correct, but I would treat it as a bug due to being incompatible with 2 major vendors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1034254</commentid>
    <comment_count>11</comment_count>
    <who name="Julien Sanchez">julien.sanchez</who>
    <bug_when>2014-09-10 02:51:03 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; fwiw, the webkit treatment appears to be spec-correct, but I would treat it as a bug due to being incompatible with 2 major vendors.

It&apos;s no more correct. The spec has been fixed last year [1]. innerHTML is now defined on Element (implemented in Chrome [2] and Firefox) *and* should create elements with correct namespace (ok in chrome [2], not yet in Firefox [3]).

[1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=17924
[2] https://code.google.com/p/chromium/issues/detail?id=311080
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=886390</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1034280</commentid>
    <comment_count>12</comment_count>
    <who name="Julien Sanchez">julien.sanchez</who>
    <bug_when>2014-09-10 06:34:33 -0700</bug_when>
    <thetext>Testcase (http://marianoguerra.github.io/bugs/svgbug/) from the following issue on Github: https://github.com/facebook/react/issues/1900 .
Webkit is also impacted as innerHTML is not defined on SVG elements.

Only the second example (&quot;innerHTML&quot;) is relevant here. 
It is certainly more complicated than just define innerHTML on Element because it should also create the &lt;text&gt; node as SVGTextElement and not as HTMLUnknownElementPrototype.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1034282</commentid>
    <comment_count>13</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2014-09-10 06:40:35 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; (In reply to comment #10)
&gt; &gt; fwiw, the webkit treatment appears to be spec-correct, but I would treat it as a bug due to being incompatible with 2 major vendors.
&gt; 
&gt; It&apos;s no more correct. The spec has been fixed last year [1]. innerHTML is now defined on Element (implemented in Chrome [2] and Firefox) *and* should create elements with correct namespace (ok in chrome [2], not yet in Firefox [3]).
&gt; 
&gt; [1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=17924
&gt; [2] https://code.google.com/p/chromium/issues/detail?id=311080
&gt; [3] https://bugzilla.mozilla.org/show_bug.cgi?id=886390

Not according to any of the DOM specs which have made it to REC, or the WHATWG&apos;s DOM.

However, this is academic, because if 2 major vendors are exposing this on Element, then it really doesn&apos;t matter what the spec says.

(In reply to comment #12)
&gt; Testcase (http://marianoguerra.github.io/bugs/svgbug/) from the following issue on Github: https://github.com/facebook/react/issues/1900 .
&gt; Webkit is also impacted as innerHTML is not defined on SVG elements.
&gt; 
&gt; Only the second example (&quot;innerHTML&quot;) is relevant here. 
&gt; It is certainly more complicated than just define innerHTML on Element because it should also create the &lt;text&gt; node as SVGTextElement and not as HTMLUnknownElementPrototype.

Yes, it&apos;s obviously necessary to use the correct parsing insertion mode. By &quot;not terribly difficult&quot; I&apos;m not saying it&apos;s a one-line patch, just that it&apos;s clear what is needed to be done.

Would you care to write the patch? I will not have time for at least 2 weeks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1034301</commentid>
    <comment_count>14</comment_count>
    <who name="Julien Sanchez">julien.sanchez</who>
    <bug_when>2014-09-10 08:14:35 -0700</bug_when>
    <thetext>
&gt; Not according to any of the DOM specs which have made it to REC, or the WHATWG&apos;s DOM.
&gt; 
&gt; However, this is academic, because if 2 major vendors are exposing this on Element, then it really doesn&apos;t matter what the spec says.

Right. I was referring to the DOM parsing living standard and latest candidate rec.

&gt; Yes, it&apos;s obviously necessary to use the correct parsing insertion mode. By &quot;not terribly difficult&quot; I&apos;m not saying it&apos;s a one-line patch, just that it&apos;s clear what is needed to be done.
&gt;
&gt; Would you care to write the patch? I will not have time for at least 2 weeks.

I would be really happy to do it. Unfortunately, I am afraid that it would be too difficult for me and presently I have neither enough time nor deep technical knowledge of Webkit to make it right and quick (within your two weeks for instance). However, I will try have a look at least out of curiosity.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1034304</commentid>
    <comment_count>15</comment_count>
    <who name="Caitlin Potter (:caitp)">caitp</who>
    <bug_when>2014-09-10 08:22:58 -0700</bug_when>
    <thetext>(In reply to comment #14)
&gt; &gt; Not according to any of the DOM specs which have made it to REC, or the WHATWG&apos;s DOM.
&gt; &gt; 
&gt; &gt; However, this is academic, because if 2 major vendors are exposing this on Element, then it really doesn&apos;t matter what the spec says.
&gt; 
&gt; Right. I was referring to the DOM parsing living standard and latest candidate rec.
&gt; 
&gt; &gt; Yes, it&apos;s obviously necessary to use the correct parsing insertion mode. By &quot;not terribly difficult&quot; I&apos;m not saying it&apos;s a one-line patch, just that it&apos;s clear what is needed to be done.
&gt; &gt;
&gt; &gt; Would you care to write the patch? I will not have time for at least 2 weeks.
&gt; 
&gt; I would be really happy to do it. Unfortunately, I am afraid that it would be too difficult for me and presently I have neither enough time nor deep technical knowledge of Webkit to make it right and quick (within your two weeks for instance). However, I will try have a look at least out of curiosity.

Cool, the Blink implementation should serve as somewhat of a guide --- it looks like much of editing/markup&apos;s API has not changed too much since the Blink fork, and the Blink innerHTML routine is just a call to createMarkup() with &quot;this&quot; (*this in the case of WebKit) and the element&apos;s childNodes --- It probably needs some adjustment to work correctly in WebKit, but following those lines is probably adequate, provided WebKit&apos;s createMarkup() is smart enough to figure out the correct insertion mode to use.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1034386</commentid>
    <comment_count>16</comment_count>
    <who name="Julien Sanchez">julien.sanchez</who>
    <bug_when>2014-09-10 13:28:56 -0700</bug_when>
    <thetext>(In reply to comment #15)
&gt; Cool, the Blink implementation should serve as somewhat of a guide --- it looks like much of editing/markup&apos;s API has not changed too much since the Blink fork, and the Blink innerHTML routine is just a call to createMarkup() with &quot;this&quot; (*this in the case of WebKit) and the element&apos;s childNodes --- It probably needs some adjustment to work correctly in WebKit, but following those lines is probably adequate, provided WebKit&apos;s createMarkup() is smart enough to figure out the correct insertion mode to use.

Thanks a lot for the guidelines. I didn&apos;t even think to look at related Blink changes. Now that I did, it doesn&apos;t seem so hard to try and adapt them.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1048829</commentid>
    <comment_count>17</comment_count>
    <who name="Damien Nozay [:dnozay]">damien.nozay</who>
    <bug_when>2014-11-14 12:04:19 -0800</bug_when>
    <thetext>see also https://bugs.webkit.org/show_bug.cgi?id=136903 (bug 136903)
there is some work in progress there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1055652</commentid>
    <comment_count>18</comment_count>
    <who name="Sylvain Galineau">galineau</who>
    <bug_when>2014-12-15 10:01:25 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 136903 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>