Re: [whatwg] WebIDL and HTML5

Garrett Smith wrote:
> There is no DOM method calld doStuff. Can you provide a concrete
> example? Boris couldn't think of one either.

Uh, what?  You never said, "I don't understand that this applies to all 
DOM methods that take a DOMString, so I'd like to have some specific 
examples."

In any case, here's a simple example:

javascript:try { alert(document.createElement(null).localName); } 
catch(e) { alert(e) }

In some UAs that alerts "null", in some it throws an exception because 
createElement("") is not valid.  Just try it.

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

The thing is, ToString is lossy.  Once called, there is no way to tell 
apart "null" and null.  However, there are DOM methods which require 
different behavior for the two (e.g. createElementNS and so forth, which 
I did explicitly mention earlier, contrary to your "counldn't think of 
one either" business).

Similarly, there are DOM methods that require different behavior for 
null and "".  Specific examples include the proposed DOM style set APIs, 
DOMImplementation.createDocument. There are also cases where returning 
null and returning "" are not equivalent.  inputEncoding is an example.

> It is not something that can or should be generally relied upon
> because it is not standardized and indeed works differently in
> implementations.

Yes.  The whole point is to standardize it.

> Considering your argument for serializing null -> "" being the most
> "sensible", I disagree.

It's sensible in the context of the large number of DOM methods that 
treat the two as equivalent (again, all the *NS methods in DOM3 Core).

-Boris

Received on Tuesday, 26 August 2008 12:38:51 UTC