Re: Elements array and query/queryAll methods

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:10 UTC