kangax wrote:
> ...
>> If the node list returns 1 element then methods like $$
>> (...).getValue() should return the value of that element.
>> (this is how jQuery handles it)
> This could lead to ambiguity. We should probably discuss it more.
I agree that it is ambiguous.  I find the selector result object one of 
the most curious and confusing aspects of jQuery.  I like the 
functionality to deal with one element separate from the functionality 
to deal with multiple elements.  I like the concept of having methods 
like NodeListWrapper#addClassName() or NodeListWrapper#setAttribute(). 
Once you start trying to merge the functionality of $() and $$(), code 
becomes hard to follow. Furthermore, unless you use $$('#mydiv') instead 
of $('mydiv') there are few cases that it is safe to assume that the 
NodeListWrapper object contains only one item.

>> I think $A should return a ListWrapper, maybe ListWrapper could be the
>> $super for NodeListWrapper.
>> ListWrapper would have methods of Array Additions and Enumerable
>> methods.
> Definitely a possibility if we stop extending Array.prototype.
> Otherwise, I don't see much usefulness in this. NodeListWrapper
> encapsulates an array of `NodeWrapper`s and its methods operate
> directly on those `NodeWrapper`. A custom `_each` and mixed-in
> Enumerable would take care of iteration. Am I missing something?
> --
> kangax
I think he means that it appears that the Enumerable mix-in concept is 
necessitated the fact that native Array objects can't inherit from 
Enumerable.  Consider this hierarchy assuming we use a ListWrapper 
instead of Array.prototype:

Enumerable (each, collect, inject, invoke, etc.)
+--ListWrapper (Enumerable + first, last, reduce, reverse, etc.)
   +--NodeListWrapper (ListWrapper + addClassName, setAttribute, etc.)
   +--ObjectRange (ListWrapper + overrides)
   +--Ajax.Responders (ListWrapper + register, unregister, dispatch)
+--Hash (Enumerable + get, set, keys, toQueryString, etc.)

- 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