kangax wrote:
> ...
> Are we going to make `ListWrapper` pretend it's an array?
> I agree that it's convenient to be able to access single elements of a
> list with brackets, but wouldn't exposing all these properties break
> the integrity/abstraction of a `ListWrapper`?
> jQuery "fills" its instance with such properties and seems to adjust
> `length` accordingly, but it's far from being an array:
> var j = $('div');
> j.length; // 14
> j[14] = 'foo';
> j.length; // 14 (not 15) - no "magic" length behavior obviously
> j.push; // undefined
> j.pop; // undefined
> j.concat; // undefined
> I think the only array-like method they have is `slice`.
> --
> kangax
I agree that ListWrapper should not try to be like an array.

In fact, I think it would be faster to have a ListWrapper#item method 
instead of extending the ListWrapper with numbered indexes:

$$W('div p').item(5);

ListWrapper.prototype.item = function(index) {
  // in this example, the element isn't even wrapped until it is accessed
  return this.raw[index] ? $W(this.raw[index]) : undefined;

Length could be a property like a browser NodeList object, but we might 
find more consistency with a ListWrapper#size method instead.

- Ken Snyder

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to