- From: Cameron McCormack <cam@mcc.id.au>
- Date: Thu, 18 Oct 2007 12:05:43 +1000
- To: public-webapi@w3.org
Hi David.
L. David Baron:
> There are a number of interfaces, used as callbacks, like
> EventListener [1], NodeFilter [2], and UserDataHandler [3], and
> XPathNSEventResolver [4] where an interface has a single method and
> is intended to be implemented by the DOM user as a callback. In
> ECMAScript bindings, the implementation typically accepts a raw
> function for such cases, in addition to (or rather than, in some
> implementations, perhaps?) an object with a named property for the
> function.
>
> Should there be an extended attribute to indicate such interfaces?
> (I'd note that Mozilla's IDL has such an extended attribute,
> [function].)
>
> (I believe Mozilla will also accept { handleEvent: my_handler } as
> an EventListener in addition to my_handler, where my_handler is a
> function, but I'm not sure whether that's true of other
> implementations. It would probably be good if the relevant
> specifications said one way or the other.)
I believe this is already handled for all such interfaces, in the last
paragraph of section 4.4:
As a special case, a Function object F is considered to implement an
interface if that interface is declared with exactly one operation.
The function itself is the implementation of the operation. If the
Function object also has a property P whose name is the name of the
operation and whose value is a Function object, then that P is used as
the implementation of the operation rather than F.
--
Cameron McCormack, http://mcc.id.au/
xmpp:heycam@jabber.org ▪ ICQ 26955922 ▪ MSN cam@mcc.id.au
Received on Thursday, 18 October 2007 02:06:05 UTC