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

Re: Detecting the "type" of a DOM object

From: David Bruant <bruant.d@gmail.com>
Date: Thu, 21 Jun 2012 17:41:23 +0200
Message-ID: <4FE340A3.8040307@gmail.com>
To: Brendan Eich <brendan@mozilla.org>
CC: Boris Zbarsky <bzbarsky@MIT.EDU>, public-script-coord@w3.org
Le 21/06/2012 17:05, Brendan Eich a écrit :
> Boris Zbarsky wrote:
>>> So in Firefox, instanceof can be used with browser API (DOM +
>>> localStorage + XHR + whatev's is built-in to the browser)
>> Stop right there. ;)  XHR has been switched to WebIDL bindings 
>> already (to ship in Firefox 14 in a few weeks), so you _can't_ use 
>> instanceof there anymore.  Other things will be following.  Hence 
>> this thread....
> Seems better to discuss and possibly revise WebIDL (and ES6, but see 
> below -- it may be ready!) first, then change Gecko, but sounds like 
> time is short to undo the change.
>>> Of course. Then +1000 for changing how instanceof is defined in WebIDL
>>> to adopt Gecko behavior!
>> The point is WebIDL can't do that on its own: there is nothing in ES5 
>> for it to hook into, as far as I know.  This needs coordination 
>> between WebIDL and the ES spec. 
> See [[NativeBrand]] in ES6 drafts including latest at
> http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts
I don't think a naive use of [[NativeBrand]] will be enough. First, 
[[NativeBrand]] is unused in instanceof. Then, a document will certainly 
have a [[NativeBrand]] of 'HTMLDocument' and returning 'true' for 
"document instanceof Node" is a bit far off.

But certainly that by making instanceof use [[NativeBrand]] and allowing 
WebIDL to hook something to make the connection between different 
[[NativeBrand]]s could do the trick.
I'll try to think about it and come up with an actual proposal.

Received on Thursday, 21 June 2012 15:42:01 UTC

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