[Prototype-core] Re: $$ function needs context attribute?

2007-10-19 Thread Tobie Langel

Hi,

That's already achieved using Element#select (formerly,
Element#getElementsBySelector).

For exemple:

$('foo').select('div.bar', 'a.baz');

is strictly equivalent to:

Selector.findChildElements($('foo'), 'div.bar', 'a.baz');

which is what your modified version of $$ wants to achieve.

In this regard, I don't see a compelling reason to complexify
Prototype's API by adding a functionality that's already present in a
clearer and more OO way.

Regards,

Tobie


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



[Prototype-core] Re: $$ function needs context attribute?

2007-10-19 Thread [EMAIL PROTECTED]

What I want is quite easy to achieve:
function $$() {
if(arguments[arguments.length-1].tagName)
return Selector.findChildElements($A(arguments).last(),
$A(arguments).slice(0,-1));
else
return Selector.findChildElements(document, $A(arguments));
}

I think this can make the $$ function to be much more flexible.

On Oct 18, 6:44 pm, "Mislav Marohni " <[EMAIL PROTECTED]>
wrote:
> On 10/18/07, Ignacio Coloma <[EMAIL PROTECTED]> wrote:
>
>
>
> > $$("").each(function(node){
> >node.getElementsBySelector("a.myclass");
> > })
>
> This snippet doesn't really do anything ...
>
> http://prototypejs.org/api/element/getelementsbyselector/
>
>
>
> > Is this what you mean?
>
> The method has been renamed to "select" in 1.6.0.
>
> I don't see what all the fuss is about, can't you just try and use this
> method instead of complaining how you would rather do it some harder way?
>
> Thanks.


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



[Prototype-core] Re: $$ function needs context attribute?

2007-10-18 Thread Mislav Marohnić
On 10/18/07, Ignacio Coloma <[EMAIL PROTECTED]> wrote:
>
>
> $$("").each(function(node){
>node.getElementsBySelector("a.myclass");
> })


This snippet doesn't really do anything ...

http://prototypejs.org/api/element/getelementsbyselector/
>
> Is this what you mean?


The method has been renamed to "select" in 1.6.0.

I don't see what all the fuss is about, can't you just try and use this
method instead of complaining how you would rather do it some harder way?

Thanks.

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



[Prototype-core] Re: $$ function needs context attribute?

2007-10-18 Thread Ignacio Coloma

$$("").each(function(node){
   node.getElementsBySelector("a.myclass");
})

http://prototypejs.org/api/element/getelementsbyselector/

Is this what you mean?

On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Oh, the "select" method, I haven't use it, and the context is
> important for the css selector, and in the case
> Selector.findChildElements supports the context, So only change  the $
> $ function and to check whether the last argument is HTML element or
> not is enough. And context is really very important for css selector,
> it make the selector much more flexible.especially in the
> $$("").each(function(node){
> $$("",node).doSomething()
> })
>
> On Oct 17, 6:43 pm, "Mislav Marohni " <[EMAIL PROTECTED]>
> wrote:
> > On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I think is is good to create a new function
> > > called "$$$" or something like that to make a short selector function
> > > and supports context.
> >
> > We use "Element#select" to constrain the lookup to a certain element:
> >
> >   $("foo").select("img")
> >
> > We discussed adding a context argument to $$ a while ago, but it just didn't
> > turn out worthwhile, I guess.
>
>
> >
>

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



[Prototype-core] Re: $$ function needs context attribute?

2007-10-17 Thread [EMAIL PROTECTED]

Oh, the "select" method, I haven't use it, and the context is
important for the css selector, and in the case
Selector.findChildElements supports the context, So only change  the $
$ function and to check whether the last argument is HTML element or
not is enough. And context is really very important for css selector,
it make the selector much more flexible.especially in the
$$("").each(function(node){
$$("",node).doSomething()
})

On Oct 17, 6:43 pm, "Mislav Marohni " <[EMAIL PROTECTED]>
wrote:
> On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > I think is is good to create a new function
> > called "$$$" or something like that to make a short selector function
> > and supports context.
>
> We use "Element#select" to constrain the lookup to a certain element:
>
>   $("foo").select("img")
>
> We discussed adding a context argument to $$ a while ago, but it just didn't
> turn out worthwhile, I guess.


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



[Prototype-core] Re: $$ function needs context attribute?

2007-10-17 Thread Mislav Marohnić
On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> I think is is good to create a new function
> called "$$$" or something like that to make a short selector function
> and supports context.


We use "Element#select" to constrain the lookup to a certain element:

  $("foo").select("img")


We discussed adding a context argument to $$ a while ago, but it just didn't
turn out worthwhile, I guess.

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