Re: Can Dispatch canDispatch()?

Garrett Smith <dhtmlkitchen@gmail.com> wrote:

> Explanation of what the proposed - EventTarget - method - hasEvent -
> would potentially do, before weighing pros and cons.
> 
> 1. document.body.hasEvent("click")
> 2. document.documentElement.hasEvent("submit")
> 3. document.forms[0].hasEvent("focus")
> 
> 1. true  -- the body will fire click
> 2. false -- this element does not fire "submit" events
> 3. true  -- this element can, if it has a tabIdex, fire focus events

I don't understand what tabindex has to do with it...?   How about:

4.  document.getElementsByTagName("span")[0].hasEvent("focus")

Now take into account that there may be a binding that allows this SPAN
element in this document to accept focus.  IOW, a simple static table is not
going to do the trick - I have to determine all this information
dynamically.  That's just not feasible, IMHO.


> The method name "hasEvent" is probably best renamed to "firesEvent".

Definitely.


> For each new event, implementers must consider "firesEvent", to make sure
> that it would not return false positives, breaking working pages.

I just don't think that is feasible, given ~75 different events and ~120
different HTML element types (I'm ignoring the non-HTML ones for now!), plus
having to compute the value at run-time.


-- 
Stewart Brodie
Software Engineer
ANT Software Limited

Received on Friday, 28 August 2009 10:19:46 UTC