@Maarten,

> If I understand your code correctly, it reads as the following CSS
> equivalent:
>
> #foo div.div_a > span.span_a

That's how I read it too.  (Nice one.)

@Marc,

I can *so* see how you went down the mental route you went down. :-)
The span is within #foo, and its parent is a div.div_a, so surely...
Maarten's translating it to straight CSS makes it clear why it's doing
what it's doing, though.  Just for added confirmation, with these
style rules:

span.span_a {
        background-color:       blue;
}
#foo div.div_a > span.span_a {
        background-color:       green;
}

...FF, IE, and Chrome all agree with Element#select:  One blue
background, two green backgrounds.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Mar 8, 4:06 pm, Maarten <maartenwie...@gmail.com> wrote:
> On Mar 8, 2:51 pm, Marc Liyanage <liyan...@gmail.com> wrote:
>
>
>
> > I am wondering if this is a bug:
>
> > <body id='body'>
>
> >         <div id='foo' class='div_a'>
> >                 <span class='span_a'></span>
> >                 <div class='div_a'>
> >                         <span class='span_a'></span>
> >                         <div class='div_a'>
> >                                 <span class='span_a'></span>
> >                         </div>
> >                 </div>
> >         </div>
>
> > </body>
>
> > I would expect
>
> > $('foo').select('div.div_a > span.span_a')
>
> > to return three span elements because three of its span descendants
> > match the selector. In fact it only returns two, the two deepest ones.
>
> Hi Marc,
>
> If I understand your code correctly, it reads as the following CSS
> equivalent:
>
> #foo div.div_a > span.span_a
>
> which indeed matches only the last two elements, as you don't select
> the first div element with class value 'div_a', because select()
> matches all elements _from_ the element with id 'foo', but if you wrap
> that element around your sets of 'div_a' elements, I expect your code
> to work as expected.
>
> Ta,
>   Maarten
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to