Re: removeEventListener with only one passed parameter...

On 6/10/14, 2:27 AM, Domenic Denicola wrote:
> It would in general be preferable for undefined and missing to have the same behavior, as in most ES functions.

WebIDL does provide a facility for this: you mark the argument as optional.

> (It seems like the takeaway here is that ? should not be used for params, and optional should be instead, to enforce normal ES semantics.)

I'm not sure why you say "instead".  The interaction of null and 
undefined for, say, a nominally object-type argument can look like one 
of the following cases:

1)  "Node arg"
2)  "optional Node arg"
3)  "Node? arg"
4)  "optional Node? arg"
5)  "optional Node? arg = null"

which have the following behavior:

1)  Throws if anything but a Node object is passed in, and requires
     something to be passed in (via arguments.length check).
2)  Throws if anything but a Node object or undefined is passed in,
     allows the argument to be missing.  Prose needs to handle the
     "not passed" (=== undefined) case.
3)  Throws if anything but a Node object, null, or undefined is passed
     in, requires something to be passed via arguments.length.
     Undefined is converted to null; prose has to handle the null case.
4)  Throws if anything but a Node object, null, or undefined is passed
     in, allows the argument to be missing.  Prose has to handle the
     separate "not passed" and "null" cases.
5)  Throws if anything but a Node object, null, or undefined is passed
     in, allows the argument to be missing. Undefined is converted to
     null; prose has to handle the null case.

Obviously you can define #4, in prose, to have the same behavior as #5 
would have....  Whether you want #4/#5 or #2 depends on whether the API 
should throw when null is passed, basically.

In any case, the spec right now has #3, and Blink implements something 
like #5, I believe.

-Boris

Received on Tuesday, 10 June 2014 13:48:18 UTC