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

RE: Solving the "how do I tell whether I have an HTML element?" (or image element, or whatever) problem

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Thu, 17 Jan 2013 21:48:31 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss <es-discuss@mozilla.org>
Message-ID: <9768D477C67135458BF978A45BCF9B3853B7D91D@TK5EX14MBXW605.wingroup.windeploy.ntdev.microsoft.com>
> From: Boris Zbarsky [mailto:bzbarsky@MIT.EDU]
> The proposal is that the expression "x instanceof Foo" where "Foo" is a
> WebIDL interface object for a non-callback interface as defined at
> http://dev.w3.org/2006/webapi/WebIDL/#interface-object will return true if
> and only "x" is a platform object implementing the relevant interface.
> So "x instanceof Element" would be true if x is an Element, no matter what
> its owner document is.

I don't think that's quite what you want. For multiple documents inside of a single window instance this is already true:

var d1 = document.implementation.createHTMLDocument("text/html");
var t1 = d1.createElement("table");
var t0 = document.createElement("table");
t0 instanceof HTMLTableElement
> true
t1 instanceof HTMLTableElement
> true
t0.ownerDocument === t1.ownerDocument
> false
(The above is IE10 current behavior)

I think you are asking that when comparing instances of elements originating from two different window objects the instanceof check can return true.

Will this be new ECMAScript 6 behavior for instanceof, or will this require some new operator/method? (I may have missed this earlier in the thread...)
Received on Thursday, 17 January 2013 21:49:38 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:08 UTC