Hi everyone,

I have only recently started to extensively use and thus appreciate
Prototype. It sure makes an enjoyable (*gasp*!) experience out of
cross browser javascripting. So thanks to everybody involved in this
project!

As I am only starting to dig into the codebase and leverage all of
prototype's features, I could be mistaken, but it appears as if CSS
selectors have been "dumbed down" in prototype's  Selector class as
used by e.g. $$(). For instance I can't select an element using $$('#My
\\.Unusual\\.Id).

In fact, a quick look into the latest released prototype.js shows the
following at line 2967:
id:           /^#([\w\-\*]+)(\b|$)/
which leads me to believe that none of the more funky CSS selector
stuff is possible.

While it is true that the HTML specification is rather restrictive [1]
when it comes to ID tokens, the same cannot be said about CSS
selectors [2]. In any case, I think it is desirable to at least
support what we can do in HTML in this regard, namely:
<element id="Id01" /> => #Id01
<element id="Id-02" /> => #Id-02
<element id="Id_03" /> => #Id_03
<element id="Id.04" /> => #Id\.04
<element id="Id:05" /> => #Id\:05

With the last THREE not supported by prototype as far as I can see.

In principle I would be willing to take a shot at implementing this if
somebody can provide me with a brief, high level overview about
Selector. This of course is unless a) I have simply overlooked
something and the functionality is already there (boy, that would be
embarrassing..), b) it was a deliberate, well thought out, decision
not to include this or c) somebody is already working on it.

Any input welcome,
Cheers,
Niels.

PS: Should this go into prototype-core?


[1]: http://www.w3.org/TR/html401/types.html#h-6.2
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").

[2]: http://www.w3.org/TR/REC-CSS2/syndata.html#q4
    *   All CSS style sheets are case-insensitive, except for parts
that are not under the control of CSS. For example, the case-
sensitivity of values of the HTML attributes "id" and "class", of font
names, and of URIs lies outside the scope of this specification. Note
in particular that element names are case-insensitive in HTML, but
case-sensitive in XML.
    * In CSS2, identifiers (including element names, classes, and IDs
in selectors) can contain only the characters [A-Za-z0-9] and ISO
10646 characters 161 and higher, plus the hyphen (-); they cannot
start with a hyphen or a digit. They can also contain escaped
characters and any ISO 10646 character as a numeric code (see next
item). For instance, the identifier "B&W?" may be written as "B\&W\?"
or "B\26 W\3F".

      Note that Unicode is code-by-code equivalent to ISO 10646 (see
[UNICODE] and [ISO10646]).
    * In CSS2, a backslash (\) character indicates three types of
character escapes.

      First, inside a string, a backslash followed by a newline is
ignored (i.e., the string is deemed not to contain either the
backslash or the newline).

      Second, it cancels the meaning of special CSS characters. Any
character (except a hexadecimal digit) can be escaped with a backslash
to remove its special meaning. For example, "\"" is a string
consisting of one double quote. Style sheet preprocessors must not
remove these backslashes from a style sheet since that would change
the style sheet's meaning.

      Third, backslash escapes allow authors to refer to characters
they can't easily put in a document. In this case, the backslash is
followed by at most six hexadecimal digits (0..9A..F), which stand for
the ISO 10646 ([ISO10646]) character with that number. If a digit or
letter follows the hexadecimal number, the end of the number needs to
be made clear. There are two ways to do that:
         1. with a space (or other whitespace character): "\26
B" ("&B")
         2. by providing exactly 6 hexadecimal digits:
"\000026B" ("&B")

      In fact, these two methods may be combined. Only one whitespace
character is ignored after a hexadecimal escape. Note that this means
that a "real" space after the escape sequence must itself either be
escaped or doubled.
    * Backslash escapes are always considered to be part of an
identifier or a string (i.e., "\7B" is not punctuation, even though
"{" is, and "\32" is allowed at the start of a class name, even though
"2" is not).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to