-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Case sensitivity of namespaced attributes of HTML elements in HTML documents #2694
Comments
Sounds very reasonable to me. Would you be up for writing a pull request and/or web platform tests? |
So you cannot match attributes with a name in uppercase? This requirement also makes it harder to reuse a parsed stylesheet across HTML and XML documents. I wonder if there's not a better solution. |
@annevk With the current spec text, you cannot match namespace-less attributes with a name in uppercase in HTML elements in HTML documents (which are also never produced by the parser). With my proposed change, that would be the case regardless of namespace. But still only on HTML elements in HTML documents. I don’t understand your point about sharing stylesheets. The "in HTML documents" bit is about the element being matched, not about the stylesheet. |
On elements in the HTML namespace in HTML documents, selector matching of attribute names is ASCII-case insensitive regardless of the attribute’s namespace. This is a change proposed in whatwg/html#2694. In the HTML spec before that change, this case-insensitivity only applies to namespace-less attributes. (Note that the HTML parser never crates namespaced attributes on HTML elements, so using the DOM’s `setAttributeNS` is necessary to create a situation where this change is observable.) This change matches Firefox 53 and Chromium 58: the number of passing/failing sub-tests didn’t change.
While editing I noticed that the previous section has very similar text:
It may make sense to make a similar change here for consistency, though this case is less annoying to implement since (unlike attribute selectors) |
On elements in the HTML namespace in HTML documents, selector matching of attribute names is ASCII-case insensitive regardless of the attribute’s namespace. This is a change proposed in whatwg/html#2694. In the HTML spec before that change, this case-insensitivity only applies to namespace-less attributes. (Note that the HTML parser never crates namespaced attributes on HTML elements, so using the DOM’s `setAttributeNS` is necessary to create a situation where this change is observable.) This change matches Firefox 53 and Chromium 58: the number of passing/failing sub-tests didn’t change.
@SimonSapin what are the chances of Selectors just defining this inline just like CSS defines how the HTML body element is special when it comes to It still seems somewhat problematic from a theoretical angle, as this precludes the addition of a namespaced attribute with an uppercase letter from being used in HTML. It's unlikely we ever wanted to make such an addition, but I doubt that if someone in the future ever did make that decision, they'd realize it would break Selectors. Whereas not introducing namespace-less attributes with uppercase letters is how HTML already works. |
@annevk Are you proposing moving the whole “4.16 Matching HTML elements using selectors and CSS” section into the Selectors spec? I don’t have an opinion on that, you’d need to propose it to the editors of that spec and CSSWG. |
Is there a performance or implementation complexity reason to prefer any namespace? |
Implementation complexity, yes. In particular for the namespace-wildcard case: when matching (For what it’s worth, Servo and Stylo share a selector matching library that can be used with different content tree data structures, so there is an abstraction boundary there.) |
On elements in the HTML namespace in HTML documents, selector matching of attribute names is ASCII-case insensitive regardless of the attribute’s namespace. This is a change proposed in whatwg/html#2694. In the HTML spec before that change, this case-insensitivity only applies to namespace-less attributes. (Note that the HTML parser never crates namespaced attributes on HTML elements, so using the DOM’s `setAttributeNS` is necessary to create a situation where this change is observable.) This change matches Firefox 53 and Chromium 58: the number of passing/failing sub-tests didn’t change.
https://html.spec.whatwg.org/multipage/scripting.html#selectors
(Emphasis added.)
Test case: https://jsfiddle.net/zbcoys5x/
In Firefox, Chrome, and Safari, the text is red. The lower-case name appears to be used for all attributes, not only namespace-less ones. Edge shows the test black, it appears to follow the spec on that point.
Note that the parser never produces an attribute where this makes a difference. Using
setAttributeNS
is required to create a namespaced attribute on an HTML element in an HTML document.I’d like the spec to be changed to align with three implementations against one by removing “namespace-less” in the paragraph quoted above:
CC @bzbarsky
The text was updated successfully, but these errors were encountered: