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

Re: [whatwg] WebIDL and HTML5

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 27 Aug 2008 09:44:42 -0700
Message-ID: <48B5847A.6090902@sicking.cc>
To: Garrett Smith <dhtmlkitchen@gmail.com>
Cc: Maciej Stachowiak <mjs@apple.com>, Boris Zbarsky <bzbarsky@mit.edu>, Web Applications Working Group WG <public-webapps@w3.org>

Garrett Smith wrote:
>>> I don't agree that that is a good way to handle null, but it is clear
>>> that these two:
>>>
>>> document.body.textContent=null;
>>> document.body.textContent='';
>>>
>>> Are specified as being different from each other. They are different
>>> because "" is the empty string and null is null. Agreed?
>> No, the spec requires the identical behavior for both. Please read again.
>>
> 
> I don't see it. Where does it say null is converted to the empty string?

It does not say to convert null to the empty string no, you are entirely 
correct there. What it does do though is describe what happens when you 
set textContent to null:

"On setting, any possible children this node may have are removed and, 
if it the new string is not empty or null, replaced by a single Text 
node containing the string this attribute is set to."

So it says to first remove all children, and then do nothing more. Do 
you share this interpretation for this one attribute?


So at this point I want to ask though: What is your proposal?

What do you propose should happen when an attribute like

   attribute DOMString nodeValue;

is set using the following ECMAScript code:

   myNode.nodeValue = "hello";
   myNode.nodeValue = "";
   myNode.nodeValue = 0;
   myNode.nodeValue = 10.2;
   myNode.nodeValue = { toString: function() { return "str"; } };
   myNode.nodeValue = new Date();
   myNode.nodeValue = null;
   myNode.nodeValue = undefined;
   myNode.nodeValue = myNode;

where myNode points to a textnode. Note that 'throw an exception' is a 
valid answer. In that case ideally also specify the exception to be 
thrown if you have an opinion.

Note that the lines should be considered separate from each other. So if 
for example the second line throws I am still interested to hear what 
the third line does etc.

Extra interesting would be to hear motivation on why you think the 
behavior you describe is the appropriate one.

Best Regards,
Jonas
Received on Wednesday, 27 August 2008 16:46:24 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:27 GMT