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

When you call a getter method then it executes on the first matched
item
NodeListWrapper.getHeight -> execute on the first matched element and
not iterate over the list
NodeListWrapper.getStyle   -> execute on ...
NodeListWrapper.getDimensions() -> ...
so $$W('#id').getHeight() -> is the same as -> $$W('#id')
[0].getHeight();

$$W('#id')[0] is an element in jQuery but if we wrap ours in  a
NodeWrapper too then
$$W('#id')[0] would be the NodeWrapper
$$W('#id')[0] instanceof NodeWrapper would be true.
$$W('#id')[0].raw() would be the element,

now we can talk about if thats too many wrappers or what not,
but I think the approach of $$(selector)<method> is a good one.

Now we could do this:
NodeWrapper.raw() -> gives you the element;
NodeWrapper.raw(element) -> sets the element;
and the internal var _raw is private;

so that by the rules above if Prototype were modified $$W -> $$, $W ->
$
$('id').raw() -> the element
$$('#id').raw() -> the element (its a getter/setter so it executes on
the first matched)

$$('.panels').hide();
$$('.panels:first').hide();

$('myPanel).raw().tagName
$('myPanel).get('tagName');

There would be no internal raw item for the NodeListWrapper because
like the jQuery object
its items are part of its indexed properties.

- JDD






--~--~---------~--~----~------------~-------~--~----~
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 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to