W3C home > Mailing lists > Public > public-html@w3.org > April 2014

Re: Elements array and query/queryAll methods

From: Dean Edwards <dean.edwards@gmail.com>
Date: Tue, 8 Apr 2014 19:11:41 +0100
Message-ID: <CAJMHKgwnKLHU_g_FLtuwqvuQ8x=vL3TgPbsTt2cD0voauC99KA@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Anne van Kesteren <annevk@annevk.nl>, Travis Leithead <travis.leithead@microsoft.com>, Eric Devine <devineej@gmail.com>, "public-html@w3.org" <public-html@w3.org>, "www-dom@w3.org" <www-dom@w3.org>
On 8 April 2014 18:43, Domenic Denicola <domenic@domenicdenicola.com> wrote:
> From: Dean Edwards <dean.edwards@gmail.com>

>> and I'm not convinced it works anyway, won't it potentially allow duplicates in the resulting Array?
>
> Why would that be a problem? JavaScript developers have duplicates in their arrays all the time.

First of all it's counter-intuitive to how I'd expect it to work - the
idea stemmed from jQuery's find() method which does not return
duplicates.

The main problem is that if I loop over the result and perform some
operation on the elements in the array (e.g. adding a child element)
then I'm potentially doing the same thing multiple times to the same
element. To stop myself from doing this I'd have to keep track of
which elements I'd already manipulated. This is slow and cumbersome
and contrary to the behaviour I'd expect.
Received on Tuesday, 8 April 2014 18:12:09 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:16:38 UTC