[whatwg] Mechanism to find available events

Ian Hickson ian at hixie.ch
Fri Apr 29 16:16:57 PDT 2011


On Wed, 29 Dec 2010, Jorge wrote:
> On 29/12/2010, at 08:27, Ian Hickson wrote:
> > On Mon, 20 Sep 2010, Biju wrote:
> >> 
> >> We need
> >> HTMLNode.getSupportedEvents()  ==> returns a text array of event names
> >> HTMLNode.isSupportedEvent(eventName)  ==> returns true/false
> >> 
> >> Many times in particular version of browser we dont know whether an
> >> HTMLNode/window support particular event.
> >> Or what are the alternate events available, so that we can refer some
> >> document or do some test to find how it can be used.
> >> So I wish we had above methods available.
> > 
> > What do you mean by "supports an event"? You can dispatch any event you 
> > want to any event target.
> 
> It's not you, it's whether *the*browser* dispatches it. Say, 
> oncontextmenu : "The code specified by this attribute is called when the 
> associated element is right-clicked or when the mouse button is held 
> down long enough to generate a contextual menu."
> 
> How could your program detect, unequivocally, that the browser it's 
> running in would dispatch an oncontextmenu when "the element is 
> right-clicked or when the mouse button is held down long enough to 
> generate a contextual menu" ?
> 
> 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.


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. :-)

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

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list