W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

Setting Node.textContent to null

From: David Flanagan <dflanagan@mozilla.com>
Date: Tue, 28 Jun 2011 12:09:29 -0700
Message-ID: <4E0A26E9.9010006@mozilla.com>
To: "www-dom@w3.org" <www-dom@w3.org>
The textContent of Node has nullable type DOMString? because some node 
types do not have text content and return null when this attribute is 
queried.

This means, however, that as far as IDL is concerned, it is legal to set 
the attribute to null on a node, and DOMCore needs to specify what 
happens when textContent is set to null for an Element, DocumentFragment 
or PI.  (The Text and Comment cases are okay because CharacterData.data 
is declared [TreatNullAs=EmptyString].)

It seems obvious that the right thing to do is to treat null as an empty 
string, but I don't think that you can declare the attribute 
[TreatNullAs=EmptyString] since that would alter the return value for 
node types that do not have text content, wouldn't it?

     David
Received on Tuesday, 28 June 2011 19:09:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:07 GMT