- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Thu, 21 Jun 2012 10:30:16 -0400
- To: David Bruant <bruant.d@gmail.com>
- CC: public-script-coord@w3.org
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. > Would it apply to non-DOM objects? That's much harder, without spec-level changes.... Obviously we could make it work on arrays, but then people will want it for their Points or whatever too, right? > I assume that by making instanceof work globally you mean breaking its > definition based on prototype object identity? Yes. In Spidermonkey there is a hook that can be attached to a given [[Class]] that will get called if the object is the RHS of instanceof and can do whatever it wants. In the case of current DOM objects it just checks whether the object implements the given interface, for example. -Boris
Received on Thursday, 21 June 2012 14:30:52 UTC