In
https://code.google.com/p/chromium/issues/detail?id=327060 I suggest
that we make attribute values in Selectors be case-sensitive by default.
This might break some sites, hence this thread.
== Background ==
Currently, some HTML attributes match their values case-insensitively in
Selectors. For example:
<input type="text">
input[type="TEXT"] { ... }
matches. This seems fine on the face of it, but the behavior in browsers
is a bit unintuitive: for performance reasons (I presume) the tag name is
not checked, only the attribute name, so e.g. <ol type="i"> or <span
type="foo"> are also case-insensitive even though <ol type> is
case-sensitive in HTML and <span type> doesn't exist. Also, this list of
case-insensitive attributes only includes "old" attributes and not e.g.
<video preload="auto"> despite that being a case-insensitive attribute in
HTML.
Selectors supports a way for authors to opt-in to case-insensitive
attribute values with an "i" flag:
input[type="TEXT" i] { ... }
== Proposal ==
Implement the "i" flag in Selectors, use it in the UA stylesheet (as
specified in the HTML spec), and make attribute values case-sensitive in
Selectors.
Old spec:
http://www.whatwg.org/specs/web-apps/2009-10-27/#selectors
New spec:
http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#case-sensitivity
Spec for "i":
http://dev.w3.org/csswg/selectors4/#attribute-case
== Impact ==
The Web compatibility impact of this change is not yet known. No other
browser has implemented this yet.
There exist tests that expect the current behavior that would need to be
updated, e.g.
http://www.css3.info/selectors-test/
This would improve performance of Selector matching according to Jens
Lindström: the performance test in
crbug.com/315087 changes from 160
runs/s to 195 runs/s.
The behavior for attribute value selectors becomes more predictable for
authors and consistent between different attributes.
== Next steps ==
If the community doesn't strongly object to this idea I think the first
order of business would be to get a better idea of the Web compat impact,
probably by adding a use counter that triggers if an attribute value
selector matches and the case was different. It might be useful to count
different attributes separately in case we have to keep the list but want
to make as short as possible.
Feedback welcome.
--
Simon Pieters
Opera Software