On Aug 21, 10:44 am, John-David Dalton <[EMAIL PROTECTED]>
> @T. J. Crowder take some time to look at the jQuery source, it might
> help with the wrapper discussion.
> I was not suggesting that $$() return a list in some cases and a
> single item in others. I was saying that
> getter/setter methods would execute on the first matched item.
> In jQuery (jQuery syntax):
> $('#footer') -> returns a jQuery instance (in our case it would be a
> NodeListWrapper);
> If you example the object it looks like:
>   NodeListWrapper[0] -> div#footer (the html element)
>   NodeListWrapper.length -> 1
>   NodeListWrapper.observe -> method
>   NodeListWrapper.toggle -> method
>   NodeListWrapper.each -> method
>   NodeListWrapper._each -> method
>   NodeListWrapper.show  -> method
>   NodeListWrapper.getValue -> method
>   NodeListWrapper.update -> method
> the jQuery object and thus our NodeListWrapper will mimic an array,
> it has a length, and index properties.

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`.

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