I like the wrapper tack (same way Ext does it). .raw doesn't sound intuitive
to me though. Why not just use .dom for the underlying element (also like
Ext)? Or .el? .raw just doesn't make for a beautiful API, IMHO :)

And no, don't make it a function call.


On Thu, Aug 21, 2008 at 10:41 AM, T.J. Crowder <[EMAIL PROTECTED]>wrote:

>
> @JDD:
>
> Thanks.  I understood your suggsetion about the accessors, I thought
> I'd also (separately) seen a suggestion that $$() return a single
> wrapped element when it only finds one, but I'm not immediately
> finding what it was that made me thing that.  Sounds like we're all on
> the same page wrt always returning a list.  Apologies for muddying the
> waters there.
>
> I disagree on the list applying accessors to only the first element.
> From an API perspective I just don't see that it makes sense.  I'd
> much rather see a first() method or property, or better yet (as I
> suggested to kangax) an explicit means of saying "give me the first
> (and only the first) element that matches this CSS spec).  If I see
> the code "list.highlight()", I'm going to expect the highlight method
> to be applied to the list, not to the first entry on the list.
>
> > Now we could do this:
> > NodeWrapper.raw() -> gives you the element;
> > NodeWrapper.raw(element) -> sets the element;
> > and the internal var _raw is private;
>
> We'll be using the raw underlying item a LOT, the last thing we want
> to do is make accessing it a function call.
>
> > There would be no internal raw item for the NodeListWrapper because
> > like the jQuery object
> > its items are part of its indexed properties.
>
> If it's not literally a wrapper, if it's a replacement, that's great
> and it's certainly the simplest solution.  But we keep calling it a
> wrapper, which is the only reason for the question about indexed
> access.
> --
> T.J. Crowder
> tj / crowder software /
>
> On Aug 21, 3:44 pm, John-David Dalton <[EMAIL PROTECTED]>
> wrote:
> > @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
> >
>


-- 
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-920-574-2218
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl

--~--~---------~--~----~------------~-------~--~----~
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