W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1998

Re: Implementing NodeList

From: Mike Champion <mcc@arbortext.com>
Date: Mon, 27 Jul 1998 20:21:46 -0400
Message-Id: <98Jul27.201807edt.26882@thicket.arbortext.com>
To: steve@crc.ricoh.com (Stephen R. Savitzky)
Cc: keshlam@us.ibm.com, www-dom@w3.org
At 07:25 PM 7/27/98 -0400, Stephen R. Savitzky wrote:
>You and Don Park need to get together on what ``liveness'' means, and when
>it's required by the spec. 
>Mike Champion <mcc@arbortext.com> writes:
>> Neither of these are consistent with the spec.  Sorry, but this *is* going
>> to be hard to implement efficiently.
>> I think the best implementation is to lazily evaluate the NodeList, i.e.,
>> make the NodeList be an interface that really has what we used to call a
>> NodeIterator under the covers.  That way, you only see nodes in the tree
>> when the user asks for them.  That puts the burden of capturing changes to
>> the tree on the call to item().
>This means that every call on item() involves a complete traversal of half
>the tree (on average) to make sure that a new node of the type selected by
>getElementsByTagName hasn't snuck in behind your back.  In the case of large
>documents, possibly containing references to external parsed entities, this
>could take a *very long time*.

Not in practice; I assure you that I screamed and yelled about this when
iterator were removed from the spec in favor of NodeLists.  I got a fair
amount of free advice to the effect that IN GENERAL people will traverse
node lists in order, so implementation tricks involving cacheing the
current location and validating that nothing has changed before accessing
the "next" index in the NodeList can mean that real performance is much
better than the worst case.

Nevertheless, the real answer -- as I think you said last time -- is to put
interators back in the spec for Level 2.

>ON THE OTHER HAND, "Don Park" <donpark@quake.net> writes
>> This confusion stems from the movement of words between different versions
>> of the spec.  If you read the latest spec more carefully, you will see that
>> the word "live" is used only in the description of the attribute
>> "childNodes".  This means that the NodeList itself is not always live and
>> that the NodeList returned by getElementsByTagName is not live.  Only the
>> NodeList returned by getChildNodes is "live".
>I think this suggests that the spec is ambiguous, and should be rewritten to
>clarify the situation, preferably in the direction of Don Park's commonsense

I agree, and I'll push for this.  Thanks for the helpful input!

Mike Champion
Received on Monday, 27 July 1998 20:21:34 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:04 UTC