Re: [whatwg] WebIDL and HTML5

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 UTC