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

Re: [DOM4] Remove Node.isSameNode

From: Jonas Sicking <jonas@sicking.cc>
Date: Thu, 15 Sep 2011 00:19:51 -0700
Message-ID: <CA+c2ei8QHosB2P4BS2=S0zQYs2LRB4kYCbeC7i+HB8F7iZXBvg@mail.gmail.com>
To: Charles Pritchard <chuck@jumis.com>
Cc: Sean Hogan <shogun70@westnet.com.au>, Webapps WG <public-webapps@w3.org>
On Fri, Sep 9, 2011 at 8:05 PM, Charles Pritchard <chuck@jumis.com> wrote:
> On 9/9/2011 6:02 PM, Jonas Sicking wrote:
>>
>> On Fri, Sep 9, 2011 at 3:42 PM, Charles Pritchard<chuck@jumis.com>  wrote:
>>>
>>> On Sep 9, 2011, at 2:27 PM, Sean Hogan<shogun70@westnet.com.au>  wrote:
>>>
>>>> On 10/09/11 3:21 AM, Jonas Sicking wrote:
>>>>>
>>>>> It's a completely useless function. It just implements the equality
>>>>> operator. I believe most languages have a equality operator already.
>>>>> Except Brainfuck [1]. But the DOM isn't implementable in Brainfuck
>>>>> anyway as it doesn't have objects, so I'm ok with that.
>>>>>
>>>>> [1] http://en.wikipedia.org/wiki/Brainfuck
>>>>>
>>>> If a DOM implementation returns  node-wrappers instead of exposing the
>>>> actual nodes then you could end up with different node-refs for the same
>>>> node. I'm not sure whether that violates other requirements of the spec.
>>>
>>> A similar method is present in the JS libs too, like jQuery. If it is
>>> necessary, is a Node.isSameType useful?
>>
>> I take it you mean "isSameNode", right?
>>
>> Do you have a pointer to the jQuery function?
>>
>> / Jonas
>>
>
> For jQuery, I think the is() method is the one; it's used for various
> things, but $(element).is($(element)) returns true, I believe.
> Typically that parameter is going to be selector, or an already existing
> variable, resulting from perhaps another selector.
>
> http://api.jquery.com/is/
>
>
>
> I meant isSameType: as a shortcut to comparing nodeType and Element local
> name.
> element.isSameType(myParagraphElement);
>
> I'm not a fan of the  if(element instanceof HTMLParagraphElement) style.
> This is just some sugar.
>
> isSameType (in the same style of isEqualNode):
> The isSameType(node) method must return true if all of the following
> conditions are true, and false otherwise:
> * node is not null.
> * node's nodeType attribute value is the same as the context object's
> nodeType attribute value.
>
> The following are also equal, depending on node:
>
> DocumentType
>    Its name, public ID, and system ID.

So it sounds like the jQuery function is infact not the same thing as
the isSameNode function. Something like the jQuery isSameType might be
more interesting, so feel free to suggest that in a separate thread.

/ Jonas
Received on Thursday, 15 September 2011 07:27:21 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:47 GMT