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

Re: [whatwg] WebIDL and HTML5

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 26 Aug 2008 12:22:39 -0400
Message-ID: <48B42DCF.5010008@mit.edu>
To: Garrett Smith <dhtmlkitchen@gmail.com>
CC: Web Applications Working Group WG <public-webapps@w3.org>

Garrett Smith wrote:
> Using ToString, the following result would be obtained:

Yes, I know what you get with ToString.

> After the method createElement(null) is called, there will be no need
> to tell apart null and "null". I see that. Why is that a problem?

There are other methods where you DO need to tell them apart, of course. 
  All the *NS methods, for example.

> You said that null -> "null" is "lossy". I don't think that's a valid
> argument. null -> "" is even more "lossy".

Yes, which is why we need a way in IDL to specify exactly what happens 
to null in different cases.  We need a one-to-many mapping here, and 
just doing a single-input-single-output function like ToString doesn't 
cover all cases.

> null and "" are not equivalent. Setting a style to have the value null
> should probably convert the value to "null"
> document.body.style.color = null;

I'd be fine with that (though I'd worry about compat issues), but that 
doesn't address the fact that in some cases null does need to be 
converted to "", or treated just like "".

> That would be a poor design choice

Which?  And on whose part?

> document.createTextNode(0)
> Should this create a textNode "0" or ""?

Or throw a typeError?

> Null is not the same as no value. Null is a type, having one value:-
> null. The value null is a primitive value in EcmaScript. It is the
> only member of the Null type.

Yes, yes.  We all know that, and you've repeated it multiple times.  I 
sort of feel like we're talking in circles here.

One last time, the facts:

1)  There are DOM methods that accept DOMString arguments or return
     DOMString values.
2)  In general, such methods need to be able to tell apart null and all
     string values (including "" and "null").
3)  The behavior of null is almost always either that of "" or that of
     "null".  Which one depends on the exact DOM method.

Therefore, the proposal is to annotate DOM DOMString arguments to DOM 
methods with some indication of whether null should be treated as "" or 
as "null", or as some value not equal to any string.  One of these three 
options can be the default; the other two then require explicit annotation.

Are we on the same page so far?

Received on Tuesday, 26 August 2008 16:23:25 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:11 UTC