This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
In ES6, there is a @@hasInstance symbol that is used to define "instanceof" behaviour. We should use that rather than defining [[HasInstance]], since it has gone from the spec.
What bug resulted in us adding an [[HasInstance]] override? I think having this is a bad idea and is future hostile. It makes it harder to move objects from the web platform into JavaScript as they will end up having subtly different behavior. (Or JavaScript's default library will end up being subtly inconsistent.) If we want better identity checks we should just introduce a method that can do it and not mess with default class semantics.
Note that there was a bunch of discussion about this on the mailing list. The idea of an isArray method or the like, whether per-interface or more generic, was strongly opposed by various people, including some TC39 folks...
While I agree that the override of [[HasInstance]] seems pretty pointless, I don't understand why it would be future-hostile. JS versions of the classes could just override their @@hasInstance, e.g. ```js class WebIDLThingy { static [Symbol.hasInstance](x) { return performBrandCheck(x); } } ```
That did not happen for e.g. ArrayBuffer. Another example would be promises, which in Gecko are implemented in terms of IDL and therefore have this "feature". bz, did we consider something like Window.ignoreGlobalInstanceOf(..., ...) as that seems hardly different from what this magic @@hasInstance override is?
> Window.ignoreGlobalInstanceOf(..., ...) Not with that name, but I think we did... I'd have to check the archives. Anyway, I'm maybe ok with people wanting to reopen this discussion if we can finally pick something, get UAs to converge on it, and stick to it. Though I will say that a fair amount of Firefox extension code has been written with the current Web IDL definition in mind, because _last_ time we had this conversation people were told we had finally decided something.
https://github.com/heycam/webidl/issues/129