W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2015

Re: WebIDL - passing undefined as optional nullable param

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Tue, 13 Jan 2015 08:44:50 -0500
Message-ID: <54B52152.4000908@mit.edu>
To: public-script-coord@w3.org
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.

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

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