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

Re: Detecting the "type" of a DOM object

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Fri, 22 Jun 2012 09:13:15 -0700
Cc: David Bruant <bruant.d@gmail.com>, Brendan Eich <brendan@meer.net>, Cameron McCormack <cam@mcc.id.au>, Boris Zbarsky <bzbarsky@mit.edu>
Message-Id: <90CA6739-1AEC-4B0B-B686-773357E5A3A4@wirfs-brock.com>
To: Tom Van Cutsem <tomvc.be@gmail.com>, es-discuss@mozilla.org
I'm going to try to move the discussion of this issue to es-discuss via a separate message as it is mostly about Proxy design. (bcc'ing public-script-coord)

the start of this subthread is the following which identifies that historically the [[HasInstance]] extension point has been used (at least conceptually) to provide alternative instanceof semantics.

On Jun 21, 2012, at 7:30 AM, Boris Zbarsky wrote:

> On 6/21/12 4:15 AM, David Bruant wrote:

>> Le 21/06/2012 07:30, Boris Zbarsky a écrit :

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

>> +1, but eternal web worry: won't it break the web?

> 

> It works cross-global for DOM objects in Gecko right now.  We're actually deliberately breaking that in the WebIDL bindings at the moment, so the actual web compat breakage for us is in the other direction: as we move to WebIDL with its stricter instanceof sites might break.




On Jun 22, 2012, at 8:14 AM, Tom Van Cutsem wrote:

> 2012/6/22 David Bruant <bruant.d@gmail.com>
> For the record, rationale for not including a trap for instanceof was described here: http://wiki.ecmascript.org/doku.php?id=harmony:proxies#interaction_with_instanceof
> 
> We've gone through this in detail before. There even was a strawman, but it got deferred, see <http://wiki.ecmascript.org/doku.php?id=strawman:proxy_instanceof>
> 
> From that strawman's "feedback" section:
> 
> "TC39 November 2010 meeting: after a meeting with the Web IDL editors, agreed that Web IDL should not expose the multiple inheritance. Hence, a custom [[HasInstance]] would not be necessary to wrap these host objects.

But the usage from FireFox that was recently identified isn't particularly related to multiple inheritance.

> 
> There may be other use cases for a custom [[HasInstance]] (outside of Web IDL), but until such cases are identified we agreed not to pursue this strawman in the interest of not further complicating the Proxy API."

This needs to be part of what we cover on es-discuss, but my position is that [HasInstance]] is a clearly defined legacy object behavior extension point.  If it isn't need it should go away entirely.  If it has utility, then it should be part of the proxy handler surface area because that the mechanism for exposing such extension points into ES code.


> 
> I don't think the new direct proxies API impacts this strawman, so technically I see no reason why proxies can't have a [[HasInstance]] trap if needed.

I agree, I don't see that it presents any technical hurdles. 

Allen
> 
Received on Friday, 22 June 2012 16:13:58 UTC

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