- From: Charles Pritchard <chuck@jumis.com>
- Date: Fri, 09 Sep 2011 20:05:24 -0700
- To: Jonas Sicking <jonas@sicking.cc>
- CC: Sean Hogan <shogun70@westnet.com.au>, Webapps WG <public-webapps@w3.org>
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.
Element
Its namespace, namespace prefix, local name.
-Charles
Received on Saturday, 10 September 2011 03:05:48 UTC