W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2008

Re: [whatwg] WebIDL and HTML5

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Mon, 25 Aug 2008 21:12:05 -0700
Message-ID: <c9e12660808252112j3bac605dk5f8ce46dbb2f0d19@mail.gmail.com>
To: "Jonas Sicking" <jonas@sicking.cc>
Cc: "Boris Zbarsky" <bzbarsky@mit.edu>, "Web Applications Working Group WG" <public-webapps@w3.org>

On Mon, Aug 25, 2008 at 6:07 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> Garrett Smith wrote:
>>>> There are probably others but I can't think of them. I think the
>>>> majority of the time that strings will want to go to ToString,
>>>> booleans will want to go to ToBoolean.
>>> That can be the default, perhaps.  But I suspect usually null should
>>> become
>>> "", not "null".
>> Why?
> Note that 'null' is generally a valid value for DOMString. This doesn't seem
> to be explicitly called out in the definition for DOMString. However there
> are lots of functions that takes a DOMString and describes what to do when
> the argument is null (as opposed to "null").
> So for a function like
>  bool doStuff(in DOMString arg);

There is no DOM method calld doStuff. Can you provide a concrete
example? Boris couldn't think of one either. Let us first investigate
some implementations.

> if null is passed there should be no need to call .toString() or any other

No, but there should be a need to call ToString.

> type of conversion is needed at all. However most functions in the DOM spec
> does not define behavior for the null value, so we have chosen to treat it
> as the the empty string as that seems like the most sensible behavior.

It is not something that can or should be generally relied upon
because it is not standardized and indeed works differently in
implementations. Please also review the example I provided earlier,
assigning an object as a css property value.

Considering your argument for serializing null -> "" being the most
"sensible", I disagree. Ecma-262 r3, Section 9.8 ToString states
clearly that null is mapped to "null". This is how the language was
designed. I do not agree that it's a "bug" or mistake.

We've been over that before. Here:


> / Jonas
Received on Tuesday, 26 August 2008 04:12:41 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 13:55:21 UTC