> With :self I could do: > > $(x).select(':self > .mixedcontent').each(...);
I don't have anything against ":self", but I don't see why $(x).select ("> .foo") shouldn't be legal syntax. > Right now this is the shortest I came up with, and it's not as concise > as I'm used to with Prototype: > > $(x).childElements().findAll(function (e) {return > e.match('.mixedcontent')}).each(...); Of course, if brevity is the main goal, there's always $$("#foo > .mixedcontent").each(...); ...but that's dramatically slower on Firefox than a $().select() (curiously, about the same speed on IE7 and Opera9, which are all I tried it on). > As an aside, getElementsBySelector()'s *documentation* describes what > I'd want in the example above, it says the method selects "extended > children", but in fact it too seems to select descendants, not children. getElementsBySelector is deprecated in favor of Element#select, which is documented correctly as retrieving descendant elements (not children). -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Mar 9, 9:36 am, Marc Liyanage <liyan...@gmail.com> wrote: > On 09.03.2009, at 01:44, Tobie Langel wrote: > > > We'll be shifting to Sizzle pretty soon, which afaik allows (or could > > easily be modified to allow) both behaviours. > > > Maybe we can make this opt-in for an upcoming release. > > That would be great, I can see both use cases. I also see that > different people seem to expect different things. It would be great to > have the implementation support both ways. > > BTW I like the idea of a :self pseudoclass a lot. > > For example, I often need to select the child (not descendant) > elements of a given element that satisfy a given selector. > > With :self I could do: > > $(x).select(':self > .mixedcontent').each(...); > > Right now this is the shortest I came up with, and it's not as concise > as I'm used to with Prototype: > > $(x).childElements().findAll(function (e) {return > e.match('.mixedcontent')}).each(...); > > :self provides the explicit link between selector evaluation and > context node that I find so surprising as default behavior. > > As an aside, getElementsBySelector()'s *documentation* describes what > I'd want in the example above, it says the method selects "extended > children", but in fact it too seems to select descendants, not children. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---