-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[selectors-4] Case-sensitive attribute selectors #2101
Comments
That's very strange! Both HTML specs (WHATWG and W3C) state that the value of this attribute should be compared case-sensitively (and the Rendering section of the both specs repeats this). The DOM value of the |
Yeah, that feels very strange! The A test case: <style>
p, foo {
display: block;
height: 2em;
}
[type=a] { background: blue; }
[type=A] { background: green; }
</style>
<p type="a"></p>
<p type="A"></p>
<foo type="a"></foo>
<foo type="A"></foo> All the boxes are green. Tested with Chrome 63 (+ Canary 65), Firefox 57 (+ Nightly 59) and Safari 11 (+ Technology Preview 45). |
Just wanted to clarify that this is specifically the type attribute, ANY other attribute works fine https://jsfiddle.net/vhed285n/1 |
https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors:
The exception seems specific to user agent stylesheet. |
Well, while this probably technically explains the issue, implying that case-sensitivity of the value of this attribute is limited to the user agent stylesheet looks like a kind of self-contradiction in the spec. The note in the spec explicitly allows "to redefine the default CSS list styles used to implement this attribute in CSS user agents"; the values I admit that it might be not easy to differentiate the |
Maybe a bit offtopic, but in Gecko, we handle I suppose that making |
My understanding was that a general agreement has been to remove as much such browser-specific magic as possible, replacing it with CSS ways to express the same behavior, even for more complicated cases like the default behavior of the |
it works properly after changing to list-b from list-A. the [] selector is case sensitive inside double quotes. BTW. For historical reasons selector "HtMl TABLE" is equivalent of "html table". The same manner for CSS: DISPLAY: TABLE works like display:table. Many developer in history write HTML/CSS code with use of only capital letters. The code is less readable but... It is fact, the sites still works. |
Looks like next quirks mode. Historical cause where "i" was not known for [] selector? Mainly for input[type...]? If we delete the manner, the old sites stop to show properly. For example HTML:
and css
Here is evidence for my words: https://jsfiddle.net/r7xm0dfx/ "disabled" works (in Cr, I don't tested FF and IE) in the same manner like "type". The type, checked and disabled were historically often stylized but the "i" was not known in past. |
@Nadya678, you are explaining the general rule. However, the HTML spec (reference provided above by @cpplearner) contains one exception from this rule specifically made for a |
After particular reading of the cited spec I think there shall be issued a bug to Chromium, Mozilla Firefox and MSIE developers. The case-insensitive checking of ol[type] selector blocks to style the numbered lists. |
I think this is therefore not a problem in the selectors-4 spec and the current issue should be closed. |
I believe that introducing the modifier to the attribute selector that makes the comparison always case-sensitive is a valid topic for [selectors-4]. Custom styling for different types of ordered lists appears to be a valid use case for it. |
Ran into the same issue as the OP. It'd be great to rely on |
Yup, this is a valid issue. It's sad that HTML now has case-insensitive-by-default matching of some attributes, and that set happens to include the one attribute that specifically needs case-sensitive handling on one element, but hey, them's the breaks. Per whatwg/html#4158 the HTML folks would like something like this, so Agenda+ for discussion. |
@tabatkins Umm, so why does that set include this attribute exactly? Not including it as case-insensitive seems to make the most sense? |
Backwards-compat reasons. |
Adding an flag here that does the opposite of the |
@tabatkins Why is it weird? It doesn't seem weird to me. Only type on OL has values which are sensitive to case, so making it the only one that's case-sensitive makes sense to me. |
The CSS Working Group just discussed
The full IRC log of that discussion<dael> Topic: Case-sensitive attribute selectors<dael> github: https://github.com//issues/2101 <dael> TabAtkins: Turns out there's a couple of HTML attributes that must be matched case insensitive in selectors. <dael> TabAtkins: We let UAs or Authors match case insensitive for UA stylesheet. Type attribute requires this. <dael> TabAtkins: ol uses type in way that requires case sensitivity <dael> TabAtkins: Because type elsewhere requires case insensitive it would be weird and bad if some were sensitive and some not. Just like we added i tag to allow authors to opt in, we can do opposite to force case sensitive. <dael> TabAtkins: Put in a UA style sheet and in a few places where author needs to match against case sensitive they use that. <dael> fantasai: I don't have obj to adding the flag. Confused as to why type attribute it's inherently case sensitive on ol <dael> dbaron: It's per attribute, not attribute+element. attribute+element is a lto more complicated and this is only use case <dael> TabAtkins: I like s as the flag. Insensitive = i, Sensistive=s <florian> +1 to "s" <dael> fantasai: Agreed <dael> astearns: Obj to adding a Sensistive 's' flag? <dael> RESOLVED: Add a Sensitive 's' flag |
Is there a way to support additional flags for matching qualities/inequalities? Such as:
So there could be multiple flags before the closing ']', they coulld be speciified in any order, but if they contradict each other (e.g. 'i' and 's'; or 'n' and 'N'...), the last one takes place: flags are evaluated in order from left to right. The idea is to support large values for attributes or pseudo-attributes containing arbitrary Unicode text (e.g. data from a large input form field or large text elements, including text fragments matched by pseudo-attributes). Those flags could also apply to regexp matchings using operators with '~' instead of '='. |
The Selectors spec says:
Could there be a similar flag for case-sensitive matching?
I needed to select
<ol>
withtype=a
ortype=A
and apply different styles to them.The desirable result is:
But this doesn’t work because browsers match
type
attributes case-insensitively, so the second style rule overwrites the first one.Thus the actual result is:
The text was updated successfully, but these errors were encountered: