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

Ticket #4368 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Attribute selector support for Selector

Reported by: devslashnull@gmail.com Assigned to: sam@conio.net
Priority: normal Milestone: 1.1
Component: Prototype Version: 1.1.0 RC1
Severity: normal Keywords: $$ selector attribute fd
Cc:

Description

Adds the ability for Selector and all dependents ($$) to use attribute selectors, like so:

$$('form#foo input[type=text]').each(function(input) {
  Element.setStyle(input, {color: 'red'});
});

Supports =, ~=, |=, existence and != (last not in spec). Tested in Firefox and Safari.

Attachments

attribute_selectors.patch (5.7 kB) - added by devslashnull@gmail.com on 03/23/06 02:31:00.
5-31.gif (27.1 kB) - added by anonymous on 05/31/06 23:46:13.
sss.gif (3.1 kB) - added by anonymous on 05/31/06 23:59:17.
tttt

Change History

03/23/06 02:31:00 changed by devslashnull@gmail.com

  • attachment attribute_selectors.patch added.

03/23/06 03:03:33 changed by anonymous

  • version set to 1.1.0 RC1.

03/23/06 17:48:19 changed by Justin Palmer

  • owner changed from sam to sam@conio.net.

03/23/06 18:31:40 changed by david

  • keywords changed from $$ selector attribute to $$ selector attribute fd.

03/25/06 21:12:22 changed by anonymous

  • milestone set to 1.1.

03/27/06 05:42:54 changed by sam

You are awesome!

03/27/06 05:43:11 changed by sam

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

(In [4061]) Add attribute selector support for Selector (and $$). Closes #4368.

03/31/06 16:30:01 changed by anonymous

isn't the '!=' form of attribute check the same as :not([key=val])

e.g. $$('form#foo input:not([type=text])').each(function(input) {

Element.setStyle(input, {color: 'red'});

});

is that a future possibility to $$ to keep it spec friendly?

03/31/06 16:41:04 changed by devslashnull@gmail.com

That's true. It probably wouldn't be too hard to add, if someone wants to take a shot. However, Sam's implementation of selectors is pretty lightweight, and most people out there probably don't need most of the psuedo-selectors. I tried to keep that in mind when adding attribute selectors.

05/24/06 12:33:16 changed by glazedginger@gmail.com

IE6 compatibility and :not(x) implementation in Ticket #5170.

05/31/06 23:46:13 changed by anonymous

  • attachment 5-31.gif added.

05/31/06 23:59:17 changed by anonymous

  • attachment sss.gif added.

tttt