Skip to content
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

Universal selector is described incorrectly #8911

Open
annevk opened this issue Jun 3, 2023 · 2 comments
Open

Universal selector is described incorrectly #8911

annevk opened this issue Jun 3, 2023 · 2 comments

Comments

@annevk
Copy link
Member

annevk commented Jun 3, 2023

https://drafts.csswg.org/selectors/#the-universal-selector says it's written like a CSS qualified name but that is wrong, as * is not a valid CSS qualified name. \* is, but is not the same as the universal selector.

Gecko appears to do this correctly for both the prefix and local name. Chromium does it correctly for the local name, but not the prefix. WebKit currently treats * and \* as equivalent, for both local name and prefix.

There's no test coverage for this currently.

This relates to #8909.

(https://drafts.csswg.org/css-namespaces/ seems correct in how it describes this, though there might be room for improvement.)

(I discovered this mismatch in https://bugs.webkit.org/show_bug.cgi?id=184604.)

@annevk
Copy link
Member Author

annevk commented Jun 3, 2023

I tend to think they should be the same. For getElementsByTagName() and XPath there exists no syntactic distinction between * meaning all and * meaning an element named *. And even when we have more liberal element names as per whatwg/dom#849 (comment) you would not be able to name an element *. So on balance I think it makes sense if * and \* end up parsed in the same way. And it would allow implementations to reuse the qualified name representation they already need.

webkit-commit-queue pushed a commit to annevk/WebKit that referenced this issue Jun 8, 2023
https://bugs.webkit.org/show_bug.cgi?id=184604
rdar://97092572

Reviewed by Antti Koivisto and Tim Nguyen.

We did not use serializeIdentifier for qualified name prefixes and
local names. E.g., x:x was not serialized as x\:x. This was previously
attempted, but it would do the wrong thing for * and thus backed out.
So now we do not escape when prefix or local name is *.

The only edge case remaining is whether the * and \* inputs should mean
the same thing. w3c/csswg-drafts#8911 will
eventually address this.

Meanwhile this seems like a solid improvement.

Also synchronize web-platform-tests/css/cssom up to upstream commit
57c5006 for real this time.
264934@main missed a couple changes.

* LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssimportrule-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssimportrule.html:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorSerialize-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorSerialize.html:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/xml-stylesheet-pi-in-doctype.xhtml:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::serializeIdentifierOrStar):
(WebCore::CSSSelector::selectorText const):

Canonical link: https://commits.webkit.org/264980@main
@dbaron
Copy link
Member

dbaron commented Jun 8, 2023

web-platform-tests/wpt#40451 adds a test with a TODO comment pointing to this issue.

mnutt pushed a commit to movableink/webkit that referenced this issue Jun 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=184604
rdar://97092572

Reviewed by Antti Koivisto and Tim Nguyen.

We did not use serializeIdentifier for qualified name prefixes and
local names. E.g., x:x was not serialized as x\:x. This was previously
attempted, but it would do the wrong thing for * and thus backed out.
So now we do not escape when prefix or local name is *.

The only edge case remaining is whether the * and \* inputs should mean
the same thing. w3c/csswg-drafts#8911 will
eventually address this.

Meanwhile this seems like a solid improvement.

Also synchronize web-platform-tests/css/cssom up to upstream commit
57c5006103146974adb3af50d325c3b6ce7153d0 for real this time.
264934@main missed a couple changes.

* LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssimportrule-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssimportrule.html:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorSerialize-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/selectorSerialize.html:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/xml-stylesheet-pi-in-doctype.xhtml:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::serializeIdentifierOrStar):
(WebCore::CSSSelector::selectorText const):

Canonical link: https://commits.webkit.org/264980@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants