This method appears to be missing something that would be quite useful. An option so that the select() method would only look through immediate children, exactly how childElements() and decendants() differ. Unless there is already a method to do this, I have not seen.. Anyone have any thoughts? Thanks Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 21, 2007 10:08 AM, Rob <raldred-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > This method appears to be missing something that would be quite > useful. > An option so that the select() method would only look through > immediate children, exactly how childElements() and decendants() > differ. > > Unless there is already a method to do this, I have not seen.. Anyone > have any thoughts? > > Thanks > Rob > > >This should be easily accomplished with Enumerable#grep[1] as grep calls match in the "expression", and Selector#match well, matches an element :) element.immediateDescendants().grep(new Selector("#some .selector")); If you really want the API to be element.select(selector, true) then you can always use Function#wrap[2] :) Best, -Nicolas [1] http://prototypejs.org/api/enumerable/grep [2] http://prototypejs.org/api/function/wrap --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You can simply rely on the CSS child combinator. Instead of using ''#anyId .anyClass'' you can use ''#anyId > .anyClass'' This will look for .anyClass elements through the immediate children of #anyId. Best, Fabio Rob escreveu:> This method appears to be missing something that would be quite > useful. > An option so that the select() method would only look through > immediate children, exactly how childElements() and decendants() > differ. > > Unless there is already a method to do this, I have not seen.. Anyone > have any thoughts? > > Thanks > Rob--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
That works fine with $$, but if you have an element already there and want to select between it''s immediate children, you can''t do element.select("> .active") Best, -Nicolas On Dec 21, 2007 2:29 PM, Fabio <fabiowgus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You can simply rely on the CSS child combinator. > > Instead of using > ''#anyId .anyClass'' > you can use > ''#anyId > .anyClass'' > This will look for .anyClass elements through the immediate children > of #anyId. > > Best, > Fabio > > Rob escreveu: > > > > This method appears to be missing something that would be quite > > useful. > > An option so that the select() method would only look through > > immediate children, exactly how childElements() and decendants() > > differ. > > > > Unless there is already a method to do this, I have not seen.. Anyone > > have any thoughts? > > > > Thanks > > Rob > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hum, indeed, didn''t think of that...! But element.immediateDescendants().grep(new Selector("#some .selector")); is kinda ugly, huh? Prototype guys should put a little sugar on this matter =) Nicolás Sanguinetti escreveu:> That works fine with $$, but if you have an element already there and > want to select between it''s immediate children, you can''t do > element.select("> .active") > > Best, > -Nicolas > > On Dec 21, 2007 2:29 PM, Fabio <fabiowgus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > You can simply rely on the CSS child combinator. > > > > Instead of using > > ''#anyId .anyClass'' > > you can use > > ''#anyId > .anyClass'' > > This will look for .anyClass elements through the immediate children > > of #anyId. > > > > Best, > > Fabio > > > > Rob escreveu: > > > > > > > This method appears to be missing something that would be quite > > > useful. > > > An option so that the select() method would only look through > > > immediate children, exactly how childElements() and decendants() > > > differ. > > > > > > Unless there is already a method to do this, I have not seen.. Anyone > > > have any thoughts? > > > > > > Thanks > > > Rob > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
In a nutshell, supporting something like this could lead to unnecessary complications in prototype''s source. See this post for more info: http://groups.google.com/group/prototype-core/browse_thread/thread/6678c73903a41df/f8be89fc29d07e2e --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 22, 2007 1:41 AM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > In a nutshell, supporting something like this could lead to > unnecessary complications in prototype''s source. > See this post for more info: > http://groups.google.com/group/prototype-core/browse_thread/thread/6678c73903a41df/f8be89fc29d07e2eYeah, I remember :) I meant that you *can''t* do that kind of selections. Fabio, I was thinking something on the lines of String.prototype.match = String.prototype.match.wrap(function(proceed, obj) { if (Object.isElement(obj)) return new Selector(this).match(obj); return proceed(obj); }); And then you can do element.immediateDescendants().grep("#some .selector"); Even more, alias immediateDescendants as children and then it''s element.children().grep("#some .selector"); which is a little nicer (and concise) IMO. -Nicolas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
"immediateDescendants" are already aliased as "children" afaik : ) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
"childElements" more precisely. Element#children is a native Safari method. On Dec 22, 6:27 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> "immediateDescendants" are already aliased as "children" afaik : )--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
you could build a filter function and iterate over the elements child nodes. var filter = function(ele){ return ele.nodeType == 1 && $ (ele).hasClassName(".active"); }; $A(ele.childNodes).findAll(filter); On Dec 22, 5:16 am, Tobie Langel <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> "childElements" more precisely. > > Element#children is a native Safari method. > > On Dec 22, 6:27 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > "immediateDescendants" are already aliased as "children" afaik : )--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---