Re: WebIDL - passing undefined as optional nullable param

On 1/13/15 3:41 AM, Janusz Majnert wrote:
> void doSomething(DOMString a, optional ErrorCallback? onError);
....
> 2. undefined is passed: doSomething("aaa", undefined);
>
> I tried tracing this through the WebIDL spec and came to the conclusion
> that case 1 should work ok. For case 2, it should throw a TypeError
> (WebIDL 4.2.23, point 1), unless there is some way that the nullability
> takes effect.

Anne already answered this for the case of "optional", but for what it's 
worth, even if the second argument were not optional passing undefined 
explicitly would not throw, precisely because of the nullability.  So 
you would land at http://heycam.github.io/webidl/#es-nullable-type and 
step 2 would convert undefined to the "null" value of the 
"ErrorCallback?" type.

-Boris

Received on Tuesday, 13 January 2015 13:45:20 UTC