Re: [WebIDL] Simplify callbacks

On Thu, Nov 10, 2011 at 12:27 PM, Anne van Kesteren <> wrote:
> On Thu, 10 Nov 2011 00:06:49 -0800, Jonas Sicking <> wrote:
>> As others have pointed out, I think this is entirely the wrong direction
>> to go.
>> The whole point of being able to pass in an object and have a function
>> called on that object is to allow the page to have an object which
>> registers as a listener to several callbacks and reacts to all of them
>> appropriately.
>> If you are just listening to a single callback you might as well use a
>> function with a closure.
>> However if all callbacks use the same function name, then we've lost
>> all advantages of using an object with member functions since all
>> callbacks would go to the same member function.
>> Instead we should encourage callbacks to use descriptive names for the
>> callback function so that it makes sense to have a observer object
>> which listens to multiple callbacks using separate functions.
> Given the many many callbacks that use handleEvent() it seems that ship has
> sailed.

It has most certainly sailed in many cases. Like for the EventListener
interface I strongly doubt that we can change it.

However if there are newer interfaces I suspect that we can change it
there. Especially if not all implementations support the
pass-in-object-rather-than-Function syntax.

And it's most certainly not sailed for interfaces not defined yet.

So in short, "consistency" is the opposite of what we want here, so we
should not create WebIDL constructs which encourages it.

/ Jonas

Received on Thursday, 10 November 2011 17:16:53 UTC