RE: Fwd: [IndexedDB] Event handlers

> -----Original Message-----
> From: annevankesteren@gmail.com [mailto:annevankesteren@gmail.com] On
> On Thu, Jan 24, 2013 at 8:55 AM, Cameron McCormack <cam@mcc.id.au> wrote:
> > It seems a bit like a layering violation for Web IDL to describe events.
> > The "EventHandler" name is already pretty suggestive about the purpose
> of
> > the attribute, IMO. :)
> 
> The main problem at the moment with on/event/ is that you cannot
> actually tell from that whether such events will be dispatched on that
> object and no others. (E.g. DOMContentLoaded is dispatched on objects,
> but has no corresponding on/event/ attribute, events for media
> elements have on/event/ attributes on HTMLElement rather than just
> <video> and <audio>, etc.) Although I suppose that is only true for
> HTMLElement/Document/Window and not true for other classes, such as
> XMLHttpRequest.
> 
> I don't think we've settled on a strategy here yet.
> 
> Maybe IDL is not the right place, but giving a listing of events
> dispatched next to the IDL might be nice for developers trying to
> figure out what the object can do.

Events are funny things. The names are just strings, and you can use that string in combination with a registration method on any object that supports the registration method. The only problem is that you have no idea whether the UA will dispatch an event corresponding to that name on the object you've chosen. The only "pseudo" indicator is the .on/event/ attributes.

I'm not proposing a solution, only to say that this is a fairly complex problem. Take IndexedDB for example, their event propagation model is fairly complex (among objects that are not in a DOM tree relationship). I haven't seen a great way to declaratively express the combination of expected propagation model, target objects, and type-binding for events yet. But if anyone has a good proposal, it would be nice to have somewhere (and it could even land as valid WebIDL syntax--maybe).

Received on Thursday, 24 January 2013 17:34:14 UTC