W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2009

Re: Dropping (or deprecating) event initialization methods

From: Morten Barklund <morten@barklund.dk>
Date: Fri, 18 Sep 2009 10:50:03 +0200 (CEST)
Message-ID: <62409.>
To: <cam@mcc.id.au>
Cc: <www-dom@w3.org>

>   * adding attributes to a parent interface, like UIEvent, would mean
>     that the intuitive argument order could not be kept in the child
>     interface's method

I find this to be the biggest problem.

If arguments of init-methods should be in order of attributes from each of
the interfaces in the inheritance chain in inheritance order, you
essentially either have to settle with the interfaces currently available
("for all eternity") or change the argument order every time an interface
is changed and breaking backwards compatibility - or once and for all
change the initialization pattern used.

> I suggest that we dispense with this pattern, and instead make all of
> the attributes that these initializer methods would set writable.  If
> assigned to during event dispatch, an exception would be thrown.

I see two combinable solutions. Either create initMethods that take
dictionaries of attributes like:

document.initMouseEvent({target: foo, relatedTarget: bar});

And/or make attributes settable during the event initialization phase and
lock them down once the event is dispatched as Cameron suggests. Both are
tricky ways to implement in some languages and easy in others. Using the
dictionary approach is though possible with the current possibilities in
the Web IDL language, but it is a foreign concept still.

Actually one could also argue, that the order of arguments should be
implementation specific, as some languages do not have the same
limitations (e.g. python with named arguments), but this is of course
necessary given the Web IDL specification language selected.

> I suppose some web content would rely on these methods currently, but I
> would guess it's not much.

Neither would I. I think the primary use case for this (in JavaScript) is
for unit testing, where scripted event creation is needed to test

Morten Barklund
Received on Friday, 18 September 2009 08:48:12 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:15 UTC