Den 29-12-2012 20:19smaug skrev:
On 12/27/2012 12:18 PM, Boris Zbarsky wrote:
We have a bunch of chrome and extension code that does things like
"instanceof HTMLAnchorElement" (and likewise with other DOM interfaces).

The problem is that per WebIDL spec and general ECMAScript sanity this
shouldn't work: instanceof goes up the proto chain looking for the
thing on the
right as a constructor, and chrome's HTMLAnchorElement is not on the
proto chain of web page elements.

The arguably "right" way to do the "el instanceof HTMLAnchorElement"
test is:

   el instanceof el.ownerDocument.defaultView.HTMLAnchorElement

Needless to say this sucks.
And doesn't work for data documents which don't have defaultView

Wouldn't this work? (for chrome code)

el instanceof Components.utils.getGlobalForObject(el).HTMLAnchorElement



_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to