Re: NodeList (Re: CSS::SAC)

At 17:02 20/03/2001 -0500, Philippe Le Hegaret wrote:
>Robin Berjon wrote:
>> In the new Perl DOMs, NodeLists aren't objects either, just plain and
>> simple arrayrefs.
>
>That seems inconsistent with the DOM spec. How does it implement the live
>aspects of NodeLists if it is an array?

As Ken explained earlier today, it's more an addition to the interface than
a reduction of it. Some minimal implementations will choose to make those
simple arrays (and thus drop the liveness) but more complex ones will
provide item() and getLength(), as well as take care of the liveness.

The array interface really makes a lot of things much easier, notably for
implementing queries with filters (ie XPath or CSS selection) over a DOM.
The fact that an array can be implemented just about any way under the hood
(using ties for instance) means that there is no loss of funcitonality if
the implementor choose so.

Similarly, using hashes for NamedNodeMaps with an underlying tie means that
both $nnmap{[%ns_uri, $lname]} and $nnmap{$qname} can work on the same
hash. Or that one can do $text_node =~ s/foo/bar/ to directly modify the
text node's value. It doesn't mean that the DOM methods aren't there, but
those are nice convience additions which one would expect to see in the
Perl world.

As per Bjoern's request, I've been adding Java/spec equivalents to SAC, and
will do the same when I'm done with CSS::DOM.

-- robin b.
Smoking is one of the leading causes of statistics.

Received on Wednesday, 21 March 2001 09:14:09 UTC