Subj : Re: instanceof XML and instanceof XMLList? To : Martin.Honnen From : Brendan Eich Date : Mon Mar 28 2005 05:53 pm Martin Honnen wrote: > So far each time I try to figure whether something is an XML object or > an XMLList object and turn to the E4X specification I end up in a > section saying something alike "This intentionally blurs the distinction > between XML objects and XMLLists". The spec tries to allow for a future unification, but it won't be easy to do 100% compatibly. See 13.4.3.10 [[HasInstance]] (V) defined in the XML constructor, which does require that for an XML or XMLList instance x, x instanceof XML will be true. This does not imply x instanceof XMLList for an XML instance x, however, and there's no override for XMLList's [[HasInstance]]. > In the above test case not even the implementations agree. Which > implementation is right in the above test case? Or is Spidermoney doing > something different in the prototype chain but both ways are allowed? SpiderMonkey unifies the prototype object for XML and XMLList, but hides methods depending on the type of the |this| parameter. Since there is only one prototype for both constructors, an instance of either is an instance of the other, according to the default Function object [[HasInstance]] internal method. I don't plan on fixing this; I'm not sure it's even a bug, given all the last-minute attempts before ECMA finalized ECMA-357 to "intentionally blur the distinction". I hope you can live with it. /be .