<?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>27424</bug_id>
          
          <creation_ts>2014-11-25 09:26:11 +0000</creation_ts>
          <short_desc>Node.isSameNode() has non-trivial usage</short_desc>
          <delta_ts>2016-03-16 06:21:17 +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</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Philip Jägenstedt">philipj</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>hober0</cc>
    
    <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>rniwa</cc>
    
    <cc>travil</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>115444</commentid>
    <comment_count>0</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-25 09:26:11 +0000</bug_when>
    <thetext>https://dom.spec.whatwg.org/#dom-node-issamenode

Chrome use counter data is around 0.01%:
https://www.chromestatus.com/metrics/feature/timeline/popularity/118

The implementation is trivial so there&apos;s little to gain from removal.

It looks like Gecko is the only engine to not support it at all, having removed it in 2012:
https://developer.mozilla.org/en-US/docs/Web/API/Node.isSameNode

In IE it behaves as if:
boolean isSameNode(Node other);

In Blink it behaves as if:
boolean isSameNode(optional Node? other = null);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115445</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-25 09:35:08 +0000</bug_when>
    <thetext>I believe Jonas was in favor of removing this. Given that Gecko succeeded, why can&apos;t Blink?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115448</commentid>
    <comment_count>2</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-25 10:15:01 +0000</bug_when>
    <thetext>It could succeed, it just seems like a harmless thing to keep around, and since it&apos;s supported everywhere except Gecko brining it back would be the simplest path to agreement between spec and browsers.

Somewhat on topic, is there any data showing that isEqualNode() is required for Web compat while isSameNode() isn&apos;t?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115449</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-25 10:18:20 +0000</bug_when>
    <thetext>Well, isSameNode() is also known as === in JavaScript. isEqualNode() is actually a novel primitive. I think that&apos;s why we decided to only try to remove the former.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115455</commentid>
    <comment_count>4</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-11-25 10:43:33 +0000</bug_when>
    <thetext>OK, let&apos;s leave isEqualNode() out of the discussion.

Jonas, how badly do you want to keep isSameNode() out of Gecko?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115469</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-11-25 14:02:43 +0000</bug_when>
    <thetext>I think the reasoning here was that having isSameNode was making web authors use it instead of ===, because they were afraid that the test was somehow different.  Which it&apos;s not; except it&apos;s slower.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116066</commentid>
    <comment_count>6</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-09 19:25:12 +0000</bug_when>
    <thetext>I gave it my best shot, but in the end we decided to neither deprecate nor remove this in Blink, on the grounds that it doesn&apos;t warrant taking even a small risk:
https://groups.google.com/a/chromium.org/d/msg/blink-dev/CpIy0Pzcg4E/k0SgkniDDNUJ

So, I&apos;d like to again request that this is revived in the spec. I appreciate that Mozilla took the risk in moving first with this and many other removals, but revival really seems like the fastest way to resolve this for good.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116067</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-12-09 19:28:20 +0000</bug_when>
    <thetext>Quite honestly, if Blink is not willing to remove this, just like they&apos;re not willing to remove their various webkit-prefixed stuff, that doesn&apos;t mean the spec should include it, unless it&apos;s actually needed for web compat.

Put another way, if we think the web compat impact of this (of which there is none that anyone knows about) requires it to be put in the spec, we should add the things that have _more_ web compat impact, like various webkit-prefixed stuff, to the spec first.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116070</commentid>
    <comment_count>8</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-09 20:51:17 +0000</bug_when>
    <thetext>Yes, webkit-prefixed and other webkit-only APIs are a bigger problem, I&apos;ve removed many of them and will try to remove as many more as possible. I don&apos;t know what to do about the ones required for Web compat, a Prefixes Standard seems like one way to go.

I don&apos;t know if isSameNode() is required for Web compat for non-Gecko browsers, and currently have no way of finding out other than attempting the removal. If isSameNode() remains in the spec, maybe someone working on Safari or IE will have better luck.

If spec&apos;d, I think it should be isSameNode(Node? node), like isEqualNode.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116079</commentid>
    <comment_count>9</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-09 23:15:51 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #8)
&gt; If isSameNode() remains in the spec, maybe someone working on
&gt; Safari or IE will have better luck.

s/in/out of/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116090</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-12-10 12:39:37 +0000</bug_when>
    <thetext>It would be interesting to know what Microsoft and Apple are doing with this method. I&apos;m inclined to leave this bug open until either Gecko feels forced to implement this or a new browser (say Servo) feels forced to implement this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116117</commentid>
    <comment_count>11</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-12-10 23:34:17 +0000</bug_when>
    <thetext>(In reply to Anne from comment #10)
&gt; It would be interesting to know what Microsoft and Apple are doing with this
&gt; method. I&apos;m inclined to leave this bug open until either Gecko feels forced
&gt; to implement this or a new browser (say Servo) feels forced to implement
&gt; this.

Well, IE is going to leave it in unless it&apos;s going to pose a problem (inertia is to not change). If it&apos;s ultimately not needed and Chrome can remove it (0.01 is lower than their tolerance limit of 0.03 to pull a feature out as I recall), then I think IE would feel good in removing it too.

Given that, not specing it is fine by me :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116118</commentid>
    <comment_count>12</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-10 23:47:53 +0000</bug_when>
    <thetext>I proposed removing it in Blink (and thus Chrome) but despite the 0.01% usage no amount of risk was deemed justified given how trivial this is to support, see comment #6.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116119</commentid>
    <comment_count>13</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2014-12-11 00:29:23 +0000</bug_when>
    <thetext>FWIW, at mozilla we&apos;ve thought of removing this function as a performance optimization. I.e. that the fallback code path that sites hopefully provide is likely faster than calling the function.

I.e. we expected code like

if (a.isSameNode ? a.isSameNode(b) : a === b) {
  // a is same as b
}

or

if (!Node.prototype.isSameNode) {
  Node.prototype.isSameNode = function(other) { return this === other; };
}


I don&apos;t recall if we made that assumption based on code in the wild or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116414</commentid>
    <comment_count>14</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-17 10:35:51 +0000</bug_when>
    <thetext>Ryosuke, do you have anything to say on the prospects of removing isSameNode() in WebKit?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116420</commentid>
    <comment_count>15</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2014-12-17 14:13:08 +0000</bug_when>
    <thetext>(In reply to Philip Jägenstedt from comment #14)
&gt; Ryosuke, do you have anything to say on the prospects of removing
&gt; isSameNode() in WebKit?

I don&apos;t have a strong opinion either way, and I haven&apos;t talked with my colleagues yet but my gut feeling is that we&apos;re not gonna remove this function; at least that&apos;s what I&apos;m going to advocate if anyone suggests to remove this function in WebKit.

As far as I&apos;ve searched through GitHub [1], most of code samples I found that uses isSameNode are WebKit/Blink tests. This contradicts the claim that removing isSameNode is a meaningful performance optimization or that many Web authors rely on this function instead of ===.

I can be convinced otherwise with a presence of more data indicating having this function is more harmful than worth the potential compatibility benefit.

[1] https://github.com/search?l=javascript&amp;p=80&amp;q=isSameNode%28&amp;ref=searchresults&amp;type=Code&amp;utf8=✓</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116421</commentid>
    <comment_count>16</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2014-12-17 14:23:31 +0000</bug_when>
    <thetext>I&apos;ll also add that one seemingly non-test code [2] I found to use isSameNode didn&apos;t seem to have any fallback.  This indicates that not only is this function usage low but in a few cases where it&apos;s used, it&apos;s required for compatibility.

[2] https://github.com/satisfeet/quetzal/blob/9b7dd19fa89a2084af3c12b6d32bdfdeba1fc9d4/app/products/views/show/index.js</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116422</commentid>
    <comment_count>17</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2014-12-17 15:34:15 +0000</bug_when>
    <thetext>Thanks, Ryosuke!

Lacking any enthusiasm for removal from IE or WebKit representatives, I think isSameNode() is here to stay, however useless. Here&apos;s my spec:

partial interface Node {
  boolean isSameNode(Node? node);
}

The isSameNode(node) method must return true if node and context object are the same object, and false otherwise.

In Blink the argument is optional, but if the above makes it into the spec I&apos;ll fix that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122382</commentid>
    <comment_count>18</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-08-03 09:24:11 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #7)
&gt; Put another way, if we think the web compat impact of this (of which there
&gt; is none that anyone knows about) requires it to be put in the spec, we
&gt; should add the things that have _more_ web compat impact, like various
&gt; webkit-prefixed stuff, to the spec first.

Given that we&apos;re now doing that in https://compat.spec.whatwg.org/ do you think we should add this method back?

Philip, we can make the argument optional. In that case it should simply return false, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122397</commentid>
    <comment_count>19</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2015-08-03 11:16:02 +0000</bug_when>
    <thetext>As of https://codereview.chromium.org/978223002 the argument is non-optional in Blink, matching the signature of isEqualNode().

Whether it actually needs to be nullable for web compat I don&apos;t know, but trying to find out doesn&apos;t seem worthwhile.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122407</commentid>
    <comment_count>20</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-08-03 15:17:20 +0000</bug_when>
    <thetext>&gt; do you think we should add this method back?

I don&apos;t know.  I was just saying the &quot;blink won&apos;t remove it&quot; argument was weaker for this method than for lots of prefixed stuff is all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125468</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2016-03-14 13:27:02 +0000</bug_when>
    <thetext>Adding it back since Gecko can&apos;t win this alone: https://github.com/whatwg/dom/commit/97f0a958bc1dcb98265d116bafdc80ae1b059823. 😟</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125470</commentid>
    <comment_count>22</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2016-03-14 13:54:44 +0000</bug_when>
    <thetext>Thanks, I like the comment too. &quot;Fortunately&quot; there are lots more interop hazards to work through that&apos;ll require our joint efforts to resolve.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125517</commentid>
    <comment_count>23</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2016-03-16 06:21:17 +0000</bug_when>
    <thetext>Tests requested in https://github.com/w3c/web-platform-tests/issues/2671</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>