[whatwg] Mechanism to find available events

Garrett Smith dhtmlkitchen at gmail.com
Fri Apr 29 17:19:24 PDT 2011


On 4/29/11, Ian Hickson <ian at hixie.ch> wrote:

[...]
>> We need a mechanism to detect accurately the features of the browser our
>> code's running in, without relying to UA sniffing madness.
>
> No such mechanism can exist without actually using the feature, because
> there's no way to guarantee that a browser will accurately report what it
> supports. Every time we've had such a feature (e.g. DOM hasFeature())
> vendors have ended up returning inaccurate values.
>

Is it possible to design something better than hasFeature?

Method hasFeature can be expected to have the problems it has because
it is not related to any specific object (Node, window, document). As
such, this method requires the implementation (browser) to make an
unreasonable generalization. Requiring the unreasonable is
unreasonable.

If instead, there were a method designed to check the object in
question, it could be specified to require the implementation also
check that object's capabilities.

I'm not suggesting unequivocal (e.g. right click triggers a context
menu) -- that seems too much. I'm suggesting a more closely related
inference check.

Is a mechanism such as this possible? Why rule it out?

>
> On Wed, 29 Dec 2010, Garrett Smith wrote:
>>
>> However, how can a program determine if a particular event is generated
>> by the browser and fired at a particular object? The `("onhashchange" in
>> window)` test should theoretically work, but as mentioned, that isn't
>> interoperable at this point.
>
> Neither is a mechanism to find out if an event is going to be fired. :-)
>

The *proposed* mechanism isn't interoperable -- is that what you're hinting at?

New events are what will need to be detected. Just like contextmenu
was not interoperable at one point. Now if, prior to that, there had
been a mechanism to determine if contextmenu events, the developer
would not know exactly under which circumstances that would occur, but
he would at least be in a better position to judge than using
existence inference?

> Let's get what we have already got implemented correctly before adding new
> features that do more or less the same thing.
>
Already got what?
-- 
Garrett



More information about the whatwg mailing list