- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Wed, 28 Nov 2012 23:31:50 -0500
- To: www-style@w3.org
On 11/28/12 7:58 PM, Tab Atkins Jr. wrote:
> In particular, it appears that FF's behavior is to do a
> case-insensitive comparison if the element is in the HTML namespace,
> and case-sensitive otherwise.
I'm not sure how you tested this, exactly, but that's not correct.
The exact behavior of Firefox for type selectors is as follows:
1) Store both the original casing of the type and the ASCII-lowercased
version when parsing the CSS selector.
2) When matching, if the element is an HTML element in an HTML
document (so the namespace is http://www.w3.org/1999/xhtml and the
document is text/html, to a first approximation) the element's
localName is compared to the ASCII-lowercased type selector.
Otherwise it's compared to the original-case type selector.
This allows us to do the right thing with SVG, and with the common case
of HTML elements, because they end up with all-lowercase localNames from
the parser, while not having to deal with the slowness that is actual
case-folding at matching time. The one drawback is that elements in the
HTML namespace in an HTML document that don't have all-lowercase
localNames become impossible to match. But it was judged that this edge
case was acceptable.
Note that this behavior matches the behavior of getElementsByTagName, as
specified at
<http://www.w3.org/TR/domcore/#concept-getelementsbytagname>. Indeed,
that's where the initial discussion about this happened. See thread
leading to http://lists.w3.org/Archives/Public/public-html/2009Apr/0080.html
You can detect the difference between this behavior and what you
described (and what seems to be specified at
<http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#selectors>)
by doing something like this:
<style>div { color: green; }</style>
<body>
<script>
var div =
document.createElementNS("http://www.w3.org/1999/xhtml", "DIV");
div.textContent = "Am I green?";
document.body.appendChild(div);
</script>
</body>
> Opera is always case-insensitive.
The testcase above shows that this is not true... at least not in the
Opera I have here.
> WK's behavior is broken in the case of SVG elements, since some of
> them have canonical names with uppercase in them.
Indeed. See thread linked to above.
> What should the correct behavior be?
See above. ;)
-Boris
Received on Thursday, 29 November 2012 04:32:21 UTC