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

Re: Detecting the "type" of a DOM object

From: Cameron McCormack <cam@mcc.id.au>
Date: Thu, 21 Jun 2012 13:20:06 +1000
Message-ID: <4FE292E6.6050000@mcc.id.au>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
I think what I really want to write is:

   if (n.is(Node))
     ...

but I don't think that will fly.  It might be handy to be able to accept 
null and return true, too, although you could do that with the new ".?" 
operator.

Here are some method names I came up with (not all serious contenders):

   Node.describes(n)
   Node.defines(n)
   Node.names(n)
   Node.characterizes(n)
   Node.labels(n)
   Node.hasInstance(n)
   Node.has(n)
   Node.isValue(n)
   Node.isClassOf(n)
   Node.isInterfaceOf(n)
   Node.isImplementedBy(n)

I like Node.has for its succinctness.  hasInstance is all right too, but 
it has the downside of looking like [[HasInstance]] which doesn't handle 
multiple globals, the thing we're trying to avoid.
Received on Thursday, 21 June 2012 03:20:41 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:06 UTC