<?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>13145</bug_id>
          
          <creation_ts>2011-07-05 15:29:30 +0000</creation_ts>
          <short_desc>Spec Element.innerText</short_desc>
          <delta_ts>2015-10-19 07:40:42 +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>Unwelcome</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc>https://github.com/whatwg/compat/issues/5</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aryeh Gregor">ayg</reporter>
          <assigned_to name="Michael[tm] Smith">mike</assigned_to>
          <cc>7raivis</cc>
    
    <cc>annevk</cc>
    
    <cc>contributor</cc>
    
    <cc>ian</cc>
    
    <cc>jonas</cc>
    
    <cc>mathias</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>robin</cc>
    
    <cc>roc</cc>
    
    <cc>travil</cc>
          
          <qa_contact>sideshowbarker+unwelcome</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50674</commentid>
    <comment_count>0</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-05 15:29:30 +0000</bug_when>
    <thetext>As discussed in this whatwg thread in February:

http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-February/030179.html

I don&apos;t know what the status is of that thread, and don&apos;t see it at a glance on the list of pending e-mail feedback, so I&apos;m filing a bug so I get a clear answer.

As I said in the thread, I recommend something like the following spec text for now:

  1. Let s be the empty string.

  2. For each descendant of the context node in tree order:

     1. If the descendant is a text node, append its data to s.

     2. If the descendant is a &lt;br&gt; element, append &quot;\n&quot; to s.

  3. Return s.

Setting should work the same as textContent.  I would also recommend a note encouraging authors to use textContent instead if available, because innerText is supported inconsistently -- Gecko doesn&apos;t support it as of now, and the other three browsers return very different values on getting for the same DOM.

As described in the thread: The behavior I suggest seems to basically match Opera.  Gecko doesn&apos;t implement innerText at all, and I found sites that don&apos;t work right in Gecko because of it.  I also found a site that sniffs for Firefox and uses textContent for it and innerText for everyone else.  IE9 and WebKit both do pretty-printing of the element contents, in a complicated and inconsistent way.  I didn&apos;t find any site that would break if innerText was defined the same as textContent, but Maciej said he was pretty sure some sites would break without the &lt;br&gt;-to-\n conversion, and Opera seems to do that.

Boris said he guessed he could live with my proposed definition.  Maciej seemed skeptical of WebKit changing.  I don&apos;t know what Microsoft thinks, but my personal guess would be they won&apos;t mind implementing the change in their next standards mode.

Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=264412</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50711</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-06 08:32:04 +0000</bug_when>
    <thetext>We hit at least one compatibility issue with not excluding &lt;script&gt;. If we are not going to make this dependent on the render tree I would rather try to remove it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50750</commentid>
    <comment_count>2</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-06 20:40:45 +0000</bug_when>
    <thetext>I&apos;ve been told in no uncertain terms that it&apos;s not practical for non-Gecko browsers to remove.  Depending on the rendering tree to the extent WebKit does, on the other hand, is insanely complicated to spec in terms of standard stuff like DOM and CSS.  Also, it potentially breaks for detached nodes (WebKit behaves totally differently in that case).  I do have an abortive effort here:

http://aryeh.name/spec/innertext/innertext.html

But Gecko people seemed pretty unhappy about this kind of complexity and rendering dependence in a DOM property.  And on the other hand, I got the impression WebKit is reluctant to rewrite their innerText implementation at all.  So I&apos;m figuring that the spec that will be implemented by the most browsers possible is one that&apos;s as simple as possible, basically just a compat shim.  If multiple implementers actually want to implement something like the innerText spec I started writing, I&apos;d be happy to resume work on it, but that wasn&apos;t my impression.

Do you have a link to info about the &lt;script&gt; issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50823</commentid>
    <comment_count>3</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-07-07 23:37:09 +0000</bug_when>
    <thetext>If webkit&apos;s behavior is implementation dependent enough that it&apos;s unlikely to get specced and implemented cross browser, and if webkit further is reluctant to change their implementation at all, there seems to be no hope of consistent behavior cross browser.

In that case I&apos;d rather leave things as is, spec-wise, and hope that implementation converge with time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50843</commentid>
    <comment_count>4</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-08 16:48:28 +0000</bug_when>
    <thetext>&quot;As is, spec-wise&quot; means there&apos;s no spec at all.  I don&apos;t think that&apos;s a good idea.  The response here makes it seem like both Microsoft and Mozilla would be okay with an approach like I outlined in comment #0:

http://lists.w3.org/Archives/Public/public-html/2011Jul/0133.html

Which is already something like what Opera does.  I&apos;ll wait for a response for WebKit and Opera in that thread, but if we can get a spec that three out of four engines are willing to implement, that&apos;s surely far better than the status quo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50844</commentid>
    <comment_count>5</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-07-08 16:54:04 +0000</bug_when>
    <thetext>Well, I&apos;m not sure that Gecko is willing to implement something unless we know that all parties are willing to go that route. For us that would just be additional code that still doesn&apos;t produce cross-browser APIs. In fact, more than anything it&apos;s likely to break more sites that it fixes since there&apos;s likely a lot of pages out there that does:

if (foo.innerText) {
  &lt;code that assumes webkit/IE behavior&gt;
}
else {
  &lt;code that uses something else&gt;
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50846</commentid>
    <comment_count>6</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-08 17:11:15 +0000</bug_when>
    <thetext>If anyone is actually doing &quot;if (foo.innerText)&quot; and running code that works in every browser but Gecko, then that just suggests there are more features that Gecko needs to support to match other browsers, no?  Gecko will probably break on other pages too in that case, so you should want to support those features anyway.  Codepaths that only work in one browser are to be expected and we have to work around them, but if a codepath can be written that works in every browser *but* one, that browser&apos;s the one that should change.

But we&apos;ll see what WebKit says.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51932</commentid>
    <comment_count>7</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-08-01 22:26:57 +0000</bug_when>
    <thetext>Okay, so hober has responded for WebKit:

http://lists.w3.org/Archives/Public/public-html/2011Jul/0430.html

The conclusion seems to be that WebKit isn&apos;t happy with anything as trivial as what I propose in comment #0, and Gecko isn&apos;t happy with anything as complicated as IE or WebKit does.  So my recommendation is that for now we go with something like comment #0 and see if browsers wind up converging in practice.  If we find significant problems, we can consider trying something more complicated at that point.  My post to the list on the subject was quoted by Maciej in full here (didn&apos;t show up in the archives itself because of From: address problems):

http://lists.w3.org/Archives/Public/public-html/2011Aug/0014.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53815</commentid>
    <comment_count>8</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:17:35 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54948</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-14 09:14:26 +0000</bug_when>
    <thetext>FWIW, I think this should end up in DOM if we do not make it rely on layout and probably end up in Editing along with Selection if it does. HTML is not really the right place.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55016</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-15 03:57:37 +0000</bug_when>
    <thetext>Agreed. Who wants it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55127</commentid>
    <comment_count>11</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-08-15 18:48:58 +0000</bug_when>
    <thetext>The algorithm in comment #0 depends on HTML, specifically &lt;br&gt;.  How can it go in DOM if it depends on HTML?  Also, if it&apos;s specced as in comment #0, it will be useless legacy cruft, so we don&apos;t want to expose it on anything other than HTMLElement, since browsers don&apos;t support it on Element and there&apos;s no reason for them to start.  So if it&apos;s defined like comment #0, it should be in HTML.

I agree that if we want to do a complicated rendering-dependent definition, this should be in the same place as Selection, which should be the editing spec.  However, currently we&apos;re not doing that no matter what, because we have no one to write the spec text.

So if it&apos;s going to be specced anywhere right now, it should be in HTML, IMO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60452</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-11-24 23:00:12 +0000</bug_when>
    <thetext>But it depends on CSS too, right? Maybe it should be its own thing...

I don&apos;t plan to touch this in the coming year or so, for what it&apos;s worth. Marking this REMIND so that it doesn&apos;t drop off the radar entirely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84156</commentid>
    <comment_count>13</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-03-09 01:06:47 +0000</bug_when>
    <thetext>If someone has the cycles to spec this, please take it. Realistically, I don&apos;t see having the cycles to work on this any time soon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111657</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-17 02:36:05 +0000</bug_when>
    <thetext>*** Bug 25159 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113616</commentid>
    <comment_count>15</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-10-22 22:39:02 +0000</bug_when>
    <thetext>Perhaps I could move this over to DOM Parsing and Serialization and take a stab at it there? IE has recently aligned out behavior more closely with WebKit for this API, so now might be a good time to write down that behavior and see where it goes...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113630</commentid>
    <comment_count>16</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-10-23 06:43:28 +0000</bug_when>
    <thetext>I don&apos;t think DOM Parsing &amp; Serialization should cover features that depend on rendering. If we are going with the WebKit/Chrome behavior it needs to be in CSS/editing or some such.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113641</commentid>
    <comment_count>17</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-10-23 14:33:36 +0000</bug_when>
    <thetext>It would be very nice to attempt to specify this without any rendering-dependence and see if that might be Web compatible, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113656</commentid>
    <comment_count>18</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2014-10-23 17:18:38 +0000</bug_when>
    <thetext>It definitely would be web-compatible in the sense of not outright breaking sites, but my understanding is WebKit (and probably IE too) isn&apos;t willing to do it.  In any event, that would just move the problem to the Selection stringifier, so it doesn&apos;t really solve anything.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113669</commentid>
    <comment_count>19</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-10-23 21:12:16 +0000</bug_when>
    <thetext>Oh, I wasn&apos;t aware that WebKit developers had considered and rejected that idea, do you have a link to that discussion?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113670</commentid>
    <comment_count>20</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-10-23 21:13:11 +0000</bug_when>
    <thetext>Have you done any testing, or how are you confident that it would be web-compatible-ish?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113674</commentid>
    <comment_count>21</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-10-23 22:21:08 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #20)
&gt; Have you done any testing, or how are you confident that it would be
&gt; web-compatible-ish?

I&apos;m pretty skeptical that it would be web-compatible to remove the dependency on layout--IE only came across our interop issue with webkit based on running into a site-compat issue, and our testing sample size is relatively small...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113686</commentid>
    <comment_count>22</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-10-24 07:21:44 +0000</bug_when>
    <thetext>OK, I have no data at all so I can&apos;t argue with that. To be clear, my idea was to consider the element types, so that e.g. &lt;p&gt; and &lt;br&gt; would insert extra line breaks. That would work as long as people don&apos;t override the display property *and* depend on it, which seems to me at least worth investigating.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113693</commentid>
    <comment_count>23</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2014-10-24 11:40:48 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #19)
&gt; Oh, I wasn&apos;t aware that WebKit developers had considered and rejected that
&gt; idea, do you have a link to that discussion?

(In reply to Philip Jägenstedt from comment #20)
&gt; Have you done any testing, or how are you confident that it would be
&gt; web-compatible-ish?

I don&apos;t remember specifically at this point.  The links to the relevant discussions are in the first comments in this thread.  My basis for saying it would be web-compatible without depending on rendering is the fact that Opera apparently got by okay for a long time using an extremely simple implementation, although apparently that wasn&apos;t perfect, as evidenced by comment 1.  Also, Gecko never implemented it at all last I checked, and very few sites break because of this.

(In reply to Travis Leithead [MSFT] from comment #21)
&gt; I&apos;m pretty skeptical that it would be web-compatible to remove the
&gt; dependency on layout--IE only came across our interop issue with webkit
&gt; based on running into a site-compat issue, and our testing sample size is
&gt; relatively small...

Interesting -- what does that site do about Gecko?  Probably it has a separate code path with UA sniffing, or it&apos;s meant to be mobile-only and just breaks on non-WebKit.

Anyway, based on my research in 2011, my conclusion was that browsers could avoid breaking practically any sites using a simple non-rendering-dependent implementation.  Things may have changed in the last three years, or it may be you hit one of the few sites that really does depend on exact behavior here.  My recollection is that it didn&apos;t look like WebKit&apos;s implementation would be sane to replicate exactly in any other UA.  But obviously, if people want to pick up the work here and at least some UAs are willing to converge, great!  :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123761</commentid>
    <comment_count>24</comment_count>
    <who name="Robert O&apos;Callahan (Mozilla)">roc</who>
    <bug_when>2015-10-19 02:48:53 +0000</bug_when>
    <thetext>Spec proposal here:
https://github.com/rocallahan/innerText-spec</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123762</commentid>
    <comment_count>25</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-10-19 07:40:42 +0000</bug_when>
    <thetext>It seems this discussion moved here:

  https://github.com/whatwg/compat/issues/5

Resolving this bug as such.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>