On 01/13/2011 10:05 PM, Aryeh Gregor wrote:
In defining the interface for Node, some of the attributes are defined
like "The parentElement attribute must return the parent node of the
context node if there is a parent and it is an Element node, or null
otherwise." while others are defined like
"""
The parentNode attribute must run these steps:
1. If the context node does not have a parent node, return null and
terminate these steps.
2. Return the parent node of the context node.
"""
They seem to be equivalent, but the first way is shorter.
IMHO the second is clearer (I also note that they do not seem to be
equivalent in this specific case).
There are a bunch of places where it says "When invoked with the same
argument the same NodeList object may be returned as returned by an
earlier call." Shouldn't this be either required or prohibited in any
given case, not left undefined?
It seems like making this a requirement would interact badly with GC
e.g. if I have some call that produces a huge NodeList that is then not
referenced, I don't want to keep it around just in case some future
script returns the same NodeList. On the other hand, there are scripts
that put calls returning identical NodeLists in inner loops. In these
cases not recreating the object every time is a big performance win.