Re: Detecting the "type" of a DOM object

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