Re: [selectors-api] Liveness versus NodeList

Gavin Kistner wrote:
> DOM Level 2 Core and DOM Level 3 Core both say:
> "The NodeList interface provides the abstraction of an ordered 
> collection of nodes, without defining or constraining how this 
> collection is implemented. NodeList objects in the DOM are live." [1] [2]
> 
> " NodeList and NamedNodeMap objects in the DOM are live; that is, 
> changes to the underlying document structure are reflected in all 
> relevant NodeList and NamedNodeMap objects. For example, if a DOM user 
> gets a NodeList object containing the children of an Element, then 
> subsequently adds more children to that element (or removes children, or 
> modifies them), those changes are automatically reflected in the 
> NodeList, without further action on the user's part. Likewise, changes 
> to a Node in the tree are reflected in all references to that Node in 
> NodeListand NamedNodeMap objects." [3] [4]

This is considered to be a bug in the DOM Core specs, which will 
hopefully be fixed by Web DOM Core, which is a proposal Simon Pieters is 
working on.

> The end of section 6 in the Selectors API explicitly contradicts or 
> attempts to override this (citing the latter section in DOM 3):
> 
> "The NodeList object returned by the querySelectorAll() method must be 
> static, not live. ([DOM-LEVEL-3-CORE], section 1.1.1) Subsequent changes 
> to the structure of the underlying document must not be reflected in the 
> NodeList object. This means that the object will instead contain a list 
> of matching Element nodes that were in the document at the time the list 
> was created." [5]

The reason this was changed was based on implementation feedback 
(specifically from WebKit, IIRC) which implemented this using the same 
NodeList interface rather than a separate StaticNodeList interface as 
was specified at the time, although the NodeList instances returned were 
still static lists.

Please let me know whether or not you are satisified with this response.

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

Received on Friday, 21 November 2008 15:26:42 UTC