W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: [DOM4] Remove Node.isSameNode

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Sat, 10 Sep 2011 04:24:07 +0200
To: Jonas Sicking <jonas@sicking.cc>
Cc: Webapps WG <public-webapps@w3.org>
Message-ID: <pvel67p2mbk4g7ic5n1esjh09ia8r6vcj2@hive.bjoern.hoehrmann.de>
* Jonas Sicking wrote:
>It's a completely useless function. It just implements the equality
>operator. I believe most languages have a equality operator already.

It's quite normal for object models to not guarantee that "the" equality
operator works for object identity comparison, COM being a prime example
where this is only guaranteed for IUnknown pointers. Leading to issues
like http://www.mail-archive.com/mozilla-xpcom@mozilla.org/msg05045.html
but that's life. It is also useful to have this as function available in
environments where "the object identity operator" is not available as a
function. In JavaScript, if function arity is ignored as is typical,

  [].some.call(nodelist, node.isSameNode, node)

can be used to check whether a node is in a node list, the "equivalent"

  [].some.call(nodelist, function(elem) { return elem === node; })

is a good bit worse if you want to use this as condition in an if block
as you would run past line length restrictions easily and would have to
put this on several lines. Using proxying wrappers is quite a common
practise http://code.activestate.com/lists/python-list/399236/ so I do
not see why everybody should spend resources removing this method. It's
widely implemented, used, solve an actual problem, has a spec and test
cases, I am not aware of bugs in widely used implementations, if all DOM
methods were like that we'd all be rejoicing.
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Saturday, 10 September 2011 02:24:33 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:23 UTC