Intent to Deprecate: Node.isSameNode()

150 views
Skip to first unread message

Philip Jägenstedt

unread,
Dec 2, 2014, 5:22:47 PM12/2/14
to blink-dev

Primary eng (and PM) emails

phi...@opera.com


Summary

Deprecate Node.isSameNode(), which means simply node1===node2.


Motivation

This has been removed from the DOM Standard and was removed in Gecko in 2012. However, it has non-zero usage so I filed a spec bug to bring it back:

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27424


The response was lukewarm. I think the strongest argument for removal is that it can trick developers into thinking it does something beyond ===.

Neither the spec nor Gecko have much reason to change course without proof that it's needed for Web compat.

Compatibility Risk

Exceptions will be thrown, so any amount of breakage is possible.


When I did a quick and dirty search in the httparchive data I found cases like "node1.isSameNode ? node1.isSameNode(node2) : node1 == node2" so not all current calls will break. I didn't categorize or count different cases.

Alternative implementation suggestion for web developers

Use node1===node2.


Usage information from UseCounter

https://www.chromestatus.com/metrics/feature/timeline/popularity/118


That's just below 0.01%.

Entry on chromestatus.com, crbug.com, or MDN

https://code.google.com/p/chromium/issues/detail?id=438383 is a tracking bug with typo included.


Requesting approval to remove too?

No, let it be deprecated for a few releases to give developers a chance to adapt.

Chris Harrelson

unread,
Dec 2, 2014, 5:32:50 PM12/2/14
to Philip Jägenstedt, blink-dev
LGTM

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Philip Rogers

unread,
Dec 2, 2014, 5:42:04 PM12/2/14
to Chris Harrelson, Philip Jägenstedt, blink-dev
There looks to be a fair bit of real usage inside Google (http://go/pdr-issamenode, apologies that it's not public).

Philip Rogers

unread,
Dec 3, 2014, 12:31:37 AM12/3/14
to Chris Harrelson, Philip Jägenstedt, blink-dev
Github's results are similar to google's usage: http://goo.gl/bQTM28. Some of these are polyfilled so it's hard to see exactly which will break. I'm not sure it's worth breaking these users for such a small win (-1 line in Node.idl).

Chris Harrelson

unread,
Dec 3, 2014, 12:01:51 PM12/3/14
to Philip Rogers, Philip Jägenstedt, blink-dev
Philip: do you think it's also not worth it to try to deprecate and see if usage decreases?

Philip Rogers

unread,
Dec 3, 2014, 2:55:52 PM12/3/14
to Chris Harrelson, Philip Jägenstedt, blink-dev
The upside here doesn't really justify the time spent deprecating and asking our users to update their code. The API itself is just one line in our codebase. isSameNode isn't unreasonable, so much so that we almost added it back to the spec.

Mark Pilgrim

unread,
Dec 3, 2014, 3:28:53 PM12/3/14
to blin...@chromium.org, chri...@chromium.org, phi...@opera.com
On Wednesday, December 3, 2014 2:55:52 PM UTC-5, Philip Rogers wrote:
The upside here doesn't really justify the time spent deprecating and asking our users to update their code. The API itself is just one line in our codebase.

The upside here is that we're doing our part to simplify the web platform and reduce the number of non-standardized things in Blink.

 
isSameNode isn't unreasonable, so much so that we almost added it back to the spec.

But we didn't.

-Mark 

Philip Jägenstedt

unread,
Dec 3, 2014, 3:30:13 PM12/3/14
to Philip Rogers, Chris Harrelson, blink-dev
I also don't think that this is time very well spent, which is why I filed https://www.w3.org/Bugs/Public/show_bug.cgi?id=27424

What might be persuasive is a list of top sites that are now broken in Gecko. Unfortunately, I haven't been able to find any in the httparchive data, despite some renewed efforts today. There are unchecked uses of isSameNode, but they're in codepaths I haven't figured out to trigger. One hopeful case is https://cex.io/ if someone wants to help out. Or maybe you have Google-internal tools to get results faster?

Philip

Philip Rogers

unread,
Dec 6, 2014, 3:07:33 PM12/6/14
to Philip Jägenstedt, Chris Harrelson, blink-dev, Ilya Grigorik
We do need a better way to collect this data without relying on private datasets. I wanted to share a little experiment based on Ilya Grigorik's BigQuery demo[1] to find isSameNode in 200GB of httparchive data. This seems like a reasonable approach for quickly running a regex over ~5M pages on the public web.

Query:
SELECT url,body FROM [httparchive:runs.2014_08_15_requests_body]
WHERE REGEXP_MATCH(body, r'\.isSameNode\(')

Probably would not break if isSameNode were removed:
1) mitsue-links javascript library (~35 pages, example: http://www.nikon.co.jp/common/js/mjl.js)

Some functionality could break if isSameNode were removed:
2) injection_graph_func.js (4 pages, example: http://www.vnphoto.net/js/injection_graph_func.js)

Philip Jägenstedt

unread,
Dec 6, 2014, 6:20:51 PM12/6/14
to Philip Rogers, Chris Harrelson, blink-dev, Ilya Grigorik
Yep, this is the same dataset that I've looked at, and it looks like
you've found the same cases that I did...

On Sat, Dec 6, 2014 at 9:07 PM, Philip Rogers <p...@chromium.org> wrote:
> We do need a better way to collect this data without relying on private
> datasets. I wanted to share a little experiment based on Ilya Grigorik's
> BigQuery demo[1] to find isSameNode in 200GB of httparchive data. This seems
> like a reasonable approach for quickly running a regex over ~5M pages on the
> public web.
>
> Query:
> SELECT url,body FROM [httparchive:runs.2014_08_15_requests_body]
> WHERE REGEXP_MATCH(body, r'\.isSameNode\(')
>
> Probably would not break if isSameNode were removed:
> 1) mitsue-links javascript library (~35 pages, example:
> http://www.nikon.co.jp/common/js/mjl.js)

This wouldn't break, they're defining a two-argument isSameNode and
never call Node.isSameNode().
I reached out to the Bing team a few days ago and they say they've fixed it:
https://twitter.com/foolip/status/540790976407953408

It wouldn't have broken, but I wanted to see if they were a measurable
part of the 0.01%.

> 3) ckeditor
> (http://www.heraldscotland.com/sites/all/libraries/ckeditor/ckeditor.js)

Note that this is only in older versions, it was removed in 2010:
http://dev.ckeditor.com/changeset/5970

In any event the usage is conditional and would not break.

> Some functionality could break if isSameNode were removed:
> 1) componentsNormal.js
> (http://r.api.no/componada/bundle/js/627XN2092033905/web/js/componentsNormal.js)

The is something called magazineDeck, included on four sites:
http://www.smp.no/
http://www.ha-halden.no/
http://www.gd.no/
http://www.rbnett.no/

None say "magazineDeck" anywhere else, so I think it's unreachable.

> 2) injection_graph_func.js (4 pages, example:
> http://www.vnphoto.net/js/injection_graph_func.js)

This is some Skype call button, included on four sites:
http://www.adata.com/
http://www.silicon-power.com/
http://www.vnphoto.net/
http://www.sistemaviral.com/

None say "skype" anywhere else, so I think it's unreachable.

> 3) https://cex.io/build/index.js

I haven't been able to convince myself that this is unreachable, but
setting a breakpoint doesn't actually reach it when interacting with
the site and it works in Firefox. A few days ago I reached out to
cex.io to ask what this stuff is, and they say they'll look into it.

Unable to find a single case that would break or is currently broken
in Firefox, I think the quickest way to resolve this issue is with
immediate removal. If it breaks anything at all, we'll revert it and
let Anne know that the removal failed and that we'd like it back in
the spec.

WDYT?

Philip

Chris Harrelson

unread,
Dec 8, 2014, 12:16:56 PM12/8/14
to Philip Jägenstedt, Philip Rogers, blink-dev, Ilya Grigorik
I'm in favor of this approach.
 

Philip

Philip Rogers

unread,
Dec 8, 2014, 1:35:56 PM12/8/14
to Chris Harrelson, Philip Jägenstedt, blink-dev, Ilya Grigorik
I still think this is a waste of time but my attempts to suppress it have failed. I'm fine moving forward with this approach since we have shown this will have almost no impact on users.

Philip Jägenstedt

unread,
Dec 8, 2014, 2:36:14 PM12/8/14
to Philip Rogers, Chris Harrelson, blink-dev, Ilya Grigorik
Yeah, this is definitely one of the least meaningful removals I've
suggested: risk of throwing exceptions, trivial to keep supporting,
and minimal long-term benefit for the Web platform. However, Mozilla
took a risk and removed it first, so I think they deserve a concrete
example of breakage to justify reverting the removal.

Given one more LGTM I'll go ahead with the removal and hope that's the
last we need to say about isSameNode().

Philip

Philip Jägenstedt

unread,
Dec 9, 2014, 2:14:44 PM12/9/14
to Philip Rogers, Chris Harrelson, blink-dev, Ilya Grigorik
We discussed this in today's API owners meeting. The worst case
scenario is that the removal shows no signs of trouble until it
reaches the stable channel, where it breaks in some big
corporate/intranet site. It'd stay broken for a few weeks until a new
stable version is released with isSameNode() restored.

The removal wouldn't measurably simplify the Web platform, and
breaking even a tiny number of sites seems not worth it. I wish I had
such a site to point at, but I don't. You can find unchecked uses of
isSameNode() on GitHub, so it probably exists somewhere in the wild.

So, we're neither going to deprecate nor remove isSameNode() at this
time. I'll suggest to revive it in the spec again:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27424

(There are plenty of more worthwhile simplifications to attempt around
DOM, for example Attr's child Text nodes.)

Philip
Reply all
Reply to author
Forward
0 new messages