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

Ticket #9739 (assigned defect)

Opened 8 months ago

Last modified 8 months ago

Selector doesn't allow full namespace

Reported by: jshannon Assigned to: savetheclocktower (accepted)
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: minor Keywords:
Cc:

Description

HTML IDs can contain: A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")

(http://htmlhelp.com/reference/html40/attrs.html -- Unfortunately, I couldn't find a similar statement on w3c.)

I've been using semicolons in my IDs for a while now and never had any problems, even in CSS files (though they need to be escaped). However, they break the selector class because of:

expr.match(/([a-z0-9_-])?([a-z0-9_-]+)(.*)/i)

I recommend

expr.match(/([a-z0-9_-])?([a-z0-9:_-]+)(.*)/i)

(note the semicolon after the 9.)

Change History

09/30/07 17:15:51 changed by Tobie

It's right here. Class names are even more liberal on that regard.

Unfortunately, complying to these standards would require escaping the ids. Else, valid constructs like '#main.error' (currently selecting the element with id = "#my_id" if it has a className of "error") would become ambiguous.

Allowing id and class attributes to be escaped ('"#main.error":empty') or some other, similar construct, is certainly feasable, but might slow down $$ by a lot to solve what really seems like an edge case (as far as I know, you're the first one mentioning this as an issue, and 1.5.1 final has been released for quite some time already).

Let's see what the other core members think about it.

09/30/07 17:25:09 changed by savetheclocktower

  • owner changed from sam to savetheclocktower.
  • status changed from new to assigned.

09/30/07 17:34:40 changed by Tobie

Just talked this over with Andrew. He was far more awake than myself and of course rightfully suggested escaping the characters rather than quoting the whole id (what was I thinking about !?). Let's see how this works out.