W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: QSA, the problem with ":scope", and naming

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Thu, 20 Oct 2011 13:37:42 +0200
Message-ID: <4EA00806.4070704@lachy.id.au>
To: Alex Russell <slightlyoff@google.com>
CC: Webapps WG <public-webapps@w3.org>, Yehuda Katz <wycats@gmail.com>, John Resig <jeresig@gmail.com>, Paul Irish <paulirish@google.com>, Cameron McCormack <cam@mcc.id.au>
On 2011-10-20 13:18, Alex Russell wrote:
> On Thu, Oct 20, 2011 at 12:05 PM, Lachlan Hunt<lachlan.hunt@lachy.id.au>  wrote:
>> We need NodeList separate from Array where they are live lists.
> No we don't. The fact that there's someone else who has a handle to
> the list and can mutate it underneath you is a documentation issue,
> not a question of type...unless the argument is that the slots should
> be non-configurable, non-writable except by the browser that's also
> holding a ref to it.

The author cannot be allowed to directly modify a live list, as such it 
must be an immutable object from the script's perspective.  Otherwise, 
things would get really complicated if this happened:

var p = document.getElementsByTagName("p");
document.body.insertBefore(document.createElement("p"), p[2]);

Where in the array would that new P element get added?

NodeLists are supposed to be live and in document order.  Ordinarily, 
that new P element would be inserted into the document and the change 
reflected in the NodeList.  By allowing an author to modify the list in 
some way, that completely breaks the way NodeLists are defined to work. 
  Now while it's arguable that live node lists were a mistake and that 
it would have been better if static Arrays were returned, we are stuck 
with them and cannot change that.

Lachlan Hunt - Opera Software
Received on Thursday, 20 October 2011 11:38:09 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:36 UTC