Re: [selectors-api] Return an Array instead of a static NodeList

On Mon, Oct 24, 2011 at 3:02 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> On 24/10/11 12:14 PM, Jonas Sicking wrote:
>>
>> Based on my testing, many methods wouldn't throw for zero-size
>> array-like objects. Similarly, methods like .push(), .unshift() and
>> .slice() wouldn't throw if no entries were actually requested to be
>> added or removed. And .reverse() wouldn't throw for single-sized
>> array-like objects.
>>
>> May or may not be a big deal though.
>
> Yeah.  IMO it's not.
>
> One thing that is difficult to reflect from the JS Array API to objects like
> HTMLInputElements.files which we might want to make mutable is that the
> former is designed to work with sparse arrays while we have typically
> considered DOM collection/list objects as dense.
>
>  myFileInput.files.length;    // let's say this is 1
>  myFileInput.files[2] = ...;  // what does this mean?

Indeed. Though I think we can deal with having holes. We'd just have
to compact whenever the list was changed (in this case if the user
modified the list of files).

/ Jonas

Received on Monday, 24 October 2011 22:40:28 UTC