- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Mon, 25 Aug 2008 21:12:05 -0700
- 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: http://lists.w3.org/Archives/Public/public-webapi/2008May/0457.html Garrett > / Jonas >
Received on Tuesday, 26 August 2008 04:12:41 UTC