W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2012

Re: Detecting the "type" of a DOM object

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 21 Jun 2012 01:30:05 -0400
Message-ID: <4FE2B15D.3010909@mit.edu>
To: public-script-coord@w3.org
On 6/20/12 11:20 PM, Cameron McCormack wrote:
> I think what I really want to write is:
> if (n.is(Node))
> ...
> but I don't think that will fly.

What if we used a catapult?  It looks _really_ nice.  ;)

The real problem with it is that it will throw for random non-DOM 
objects, which we really can't require to have is() on them....

How much would people hate a "n is Node" language feature akin to 
instanceof but more flexible?

Alternately, we could try to make instanceof actually work cross-global?

> Node.isInterfaceOf(n)
> Node.isImplementedBy(n)

I like these two, I guess, of the list of suggestions.

Received on Thursday, 21 June 2012 05:30:34 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:06 UTC