- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Fri, 19 Jul 2013 23:46:30 -0400
- To: "public-script-coord@w3.org" <public-script-coord@w3.org>
I've brought this up before: there is nothing in the DOM that allows reliably detecting DOM objects that implement a given interface. Something like Array.isArray or ArrayBuffer.isView as defined in ES. Last time this came up we had sort of agreed to make instanceof kinda work for this by making it consider brands in addition to proto chains, but this has a problem: HTMLElement.prototype instanceof Node is very much true (and web pages depend on this behavior, as I recall) but HTMLElement.prototype is most definitely not something that would pass a sane isNode() check... Now I suppose spec authors could add such things ad-hoc (e.g. add a "static boolean isNode(any arg)" on Node and define it in prose to return true if and only if arg is a Node). But maybe there should be a way to either express this in IDL or the default behavior should be to have such methods? -Boris
Received on Saturday, 20 July 2013 03:46:59 UTC