W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Re: Consensus on the gray areas of the DOM API

From: <keshlam@us.ibm.com>
Date: Mon, 12 Oct 1998 17:13:44 -0400
To: www-dom@w3.org
Message-ID: <8525669B.0071BC13.00@us.ibm.com>
You remember almost correctly... Apologies if I was unclear; let's try it
again.

An Attr with no children is a legitimate object. It should have a
getLength() value of 0, and return false when asked hasChildNodes().

An Attr with one child, that being an empty Text node, is also a legitimate
object. It should have a getLength() value of 1, and return true when asked
hasChildNodes().

In other words, this doesn't require any special-case handling; just tell
the truth.

It isn't clear from the REC whether Attr.setValue("") should result in the
former case or the latter. I _think_ this can be safely left up to the
implementation, as long as the actual situation is correctly reported when
folks ask whether children exist, and as long as both return "" when a
getValue() is issued.  Since both cases are possible, code has to be
prepared to deal with both; "a difference that makes no difference is no
difference."

Just so folks know how I'm biased: In my implementation, a newly-created
Attr has no children, and Attr.setValue("") replaces the previous contents
(if any) with an empty text node. Both cases return "" as their getValue()
response. For now, setValue(null) happens to reset the Attr back to its
no-children case ... that's a behavior definitely not covered by the REC,
but I hate the thought of throwing an exception when there's a reasonable
interpretation of the request.


"Unofficial and Entirely Disagreeable" -- remember to add "But much
appreciated"! <g> As I said, despite my quibbles I like the idea of getting
these not-quite-errata nailed down more tightly, and the best way to do so
is to put them up as clear unambiguous statements and see which side, if
either, gets shot at.

______________________________________
Joe Kesselman  / IBM Research
Unless stated otherwise, all opinions are solely those of the author.
Received on Monday, 12 October 1998 17:09:05 GMT

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