W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Re: [WebIDL] Simplify callbacks

From: Anne van Kesteren <annevk@opera.com>
Date: Thu, 15 Dec 2011 09:29:17 +0100
To: public-script-coord@w3.org
Message-ID: <op.v6iu63s264w2qv@annevk-macbookpro.local>
On Thu, 15 Dec 2011 02:52:13 +0100, Cameron McCormack <cam@mcc.id.au>  
> Luckily that is constants and not attributes, and there is no strict  
> need to have the NodeFilter callback be the same as the interface on  
> which those constants are defined:
>    interface NodeFilter {
>      const ...;
>    };
>    callback NodeFilterCallback = unsigned short acceptNode(Node node);

Yeah if we can make it that I think that would be great. I'm not really  
sure what the implications are but if everyone thinks this can work lets  
do it.

>>> callback EventListener = void handleEvent(Event evt);
>>> typedef [FunctionOnly] EventListener EventListenerAttribute;
>>> attribute EventListenerAttribute onclick;
>> I think we should introduce a native IDL type "eventhandler" so you can
>> write
>> eventhandler onclick;
>> Event handlers are extremely common and worthy of such blessing, in my
>> opinion.
> That makes Web IDL have a dependency on DOM Core.  Seems a bit  
> backwards.  Why not just include the typedef in DOM Core itself?

Oh, because of the callback argument. I see. I was hoping we could somehow  
get rid of [FunctionOnly] as it is only needed for this.

>    // This line you need to include anyway in DOM Core, for
>    // addEventListener to use.
>    callback EventListener = void handleEvent(Event evt);
>    // So you're just adding this one line:
>    typedef [FunctionOnly] EventListener EventHandler;
> And all specs defining event handler properties just do:
>    attribute EventHandler onclick;

I guess that is fair enough. Though HTML should include the typedef as  
HTML defines event handler attributes at the moment.

Anne van Kesteren
Received on Thursday, 15 December 2011 08:29:59 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC