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.

For now we're violating the spec in a few ways and hacking things like the above to work, but that involves preserving the nsIDOMHTML* interfaces, which we'd like to get rid of to reduce memory usage and whatnot.

So the question is how we should make the above work sanely. I've brought up the problem a few times on public-script-coord and whatnot, but there seems to not be much interest in solving it, so I think we should take the next step and propose a specific solution that we've already implemented.

One option is to model this on the Array.isArray method ES has. We'd have to figure out how to name all the methods.

Other ideas?

No matter what we'd then need to migrate our chrome and extensions to the new setup, so I'd rather not change this more than once. Especially for extensions.

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

Reply via email to