Kartikaya Gupta wrote:
On Thu, 10 Jul 2008 08:10:09 +0200, Lachlan Hunt
<[EMAIL PROTECTED]> wrote:
Do you use hasFeature() to detect the presence of any other DOM
APIs? If so, when and why?
We use feature strings to detect whether or not the DOM
implementation supports creating/dispatching certain types of
(custom) events. This allows a decoupling of code that uses the DOM
with the DOM implementation itself, and allows for independently
upgradable components. Some parts of the code also require additional
DOM functionality beyond what is provided by the standard APIs. This
is exposed via additional interfaces on various DOM objects and
feature strings are used to ensure that the DOM provides
implementations of these interfaces. Again, this is largely to
achieve modularity; it allows the "external" code to be maintained
separately rather than tying it to our specific DOM implementation.
Hypothetically speaking, if we were to implement something like Gears
in Java, it would also be using feature strings extensively to detect
the presence or absence of various features.
Would it be acceptable if I defined one, but made it optional for
implementers to support? Or at least optional for ECMAScript
implementations? That way an implementation can choose to support it if
feature detection is necessary for the language and there is no other
way to do it.
--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/