W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

RE: Maybe we should think about Interface.isInterface functions again

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Sat, 20 Jul 2013 05:36:36 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <c52e95df06c6427e910df723433ff87c@BLUPR03MB245.namprd03.prod.outlook.com>
Well, we can start grass-roots-style with DOM4/5 and at least give the basic DOM structural objects this type of detection. If you then extend this to HTML, you're probably covering 90% of the use cases...

________________________________________
From: Boris Zbarsky <bzbarsky@MIT.EDU>
Sent: Friday, July 19, 2013 8:46 PM
To: public-script-coord@w3.org
Subject: Maybe we should think about Interface.isInterface functions again

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 05:37:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC