Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8618 (new defect)

Opened 1 year ago

Last modified 2 months ago

Attribute selector not working well in 1.5.1

Reported by: ibc Assigned to: savetheclocktower
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: major Keywords:
Cc: Tobie

Description

I have a #tree with many:

<li class="no-child>...</li> <li>...</li>

That's, there are <li> with class "no-child" and <li> with no class.

In Prototype 1.5.0 I use the following line to take all the li elements without class "no-child" inside the #tree div:

$$('#tree li[class!="no-child"]')

Now I've upgraded to 1.5.1 and it doesn't work.

I've investigated and it occurs because <li> elements without class="no-child" they have NO class. If for example I put:

<li class="no-child>...</li> <li>...</li> <li class="anything">...</li>

then my code:

$$('#tree li[class!="no-child"]')

JUST selects the <li> with class="anything". That is: if you want to select all the elements with an attribute different of XXXX then those elements NEED to have that attribute with a different value, but those elements with no value for that attribute will not be selected.

I think this is a big bug.

Change History

06/09/07 15:03:53 changed by Tobie

!=is not a valid CSS3 selector.

Use the :not() selector instead:

$$('#tree li:not(.no-child)')

should work much better.

06/09/07 15:22:33 changed by ibc

  • status changed from new to closed.
  • resolution set to invalid.

Yes, thanks, it works ;)

I am trying now some things to selecting elements without "title" attribute or "title" != "KK" so:

All "a" without title attribute:

$$('a:not([title])')

All "a" without title attribute or title != "KK":

$$('a:not([title=="KK"])')

Now I understand it but I suggest you (developers) to include more examples in the API doc about those selectors.

Thanks for all and regards.

PD: I mark this bug as "invalid".

06/10/07 17:27:54 changed by savetheclocktower

  • status changed from closed to reopened.
  • resolution deleted.

It's a valid bug — != behaves one way in 1.5.0 and another way in 1.5.1. We'll fix this in the next version.

03/27/08 21:57:57 changed by jdalton

  • cc set to Tobie.
  • owner changed from sam to savetheclocktower.
  • status changed from reopened to new.

Andrew/Tobie please close this if this has been dealt with....