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

Re: WebIDL - passing undefined as optional nullable param

From: Anne van Kesteren <annevk@annevk.nl>
Date: Tue, 13 Jan 2015 09:50:11 +0100
Message-ID: <CADnb78he26tQNc2BytsRJJtCjohVKviPTqSH2+coUZ54MkL2uQ@mail.gmail.com>
To: Janusz Majnert <j.majnert@samsung.com>
Cc: public-script-coord <public-script-coord@w3.org>
On Tue, Jan 13, 2015 at 9:41 AM, Janusz Majnert <j.majnert@samsung.com> wrote:
> void doSomething(DOMString a, optional ErrorCallback? onError);
> I'm trying to find out if exceptions should be thrown in the following
> cases:
> 1. The optional argument is not given: doSomething("aaa");
> 2. undefined is passed: doSomething("aaa", undefined);

In neither case.

> 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.

You're reading it wrong. You want:


which at some point links


which defines in substep 4 of step 10 how undefined and optional go
together. Some other steps there are relevant too to complete the
picture. Hopefully this helps.

Received on Tuesday, 13 January 2015 08:50:34 UTC

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