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

[css-selectors-4] Grammar of ns-prefix incorrect? #10016

Closed
pyoor opened this issue Feb 29, 2024 · 2 comments
Closed

[css-selectors-4] Grammar of ns-prefix incorrect? #10016

pyoor opened this issue Feb 29, 2024 · 2 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. selectors-4 Current Work

Comments

@pyoor
Copy link

pyoor commented Feb 29, 2024

I'm sorry if I missed this but I couldn't find an explanation of this syntax anywhere. Currently, the syntax for ns-prefix is as follows:

<dfn noexport>&lt;ns-prefix></dfn> = [ <<ident-token>> | '*' ]? '|'

Is it intended that | is required if no ident-token or wildcard is specified? That would mean that selectors such as |* are valid. Is that the case?

@Loirooriol Loirooriol added the selectors-4 Current Work label Feb 29, 2024
@Loirooriol
Copy link
Contributor

Is it intended that | is required if no ident-token or wildcard is specified?

It's not required to specify | in a type selector like div, because both consumers make it optional: <ns-prefix>?

That would mean that selectors such as |* are valid. Is that the case?

Yes. See this XHTML example (requires application/xhtml+xml):

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<style>|* { background: green }</style>
<div xmlns="">Green</div>
</html>

In HTML it may be weirder to have elements without a namespace, but also possible:

<!DOCTYPE html>
<style>|* { background: green }</style>
<script>
var el = document.createElementNS("", "div");
el.textContent = "Green";
document.documentElement.appendChild(el);
</script>

@Loirooriol Loirooriol added the Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. label Feb 29, 2024
@Loirooriol
Copy link
Contributor

BTW, the meaning is in https://drafts.csswg.org/selectors-4/#type-nmsp

  • |E
    elements with name E without a namespace

And then as per https://drafts.csswg.org/selectors-4/#the-universal-selector it also works if you use * instead of an element E.

Like a type selector, the universal selector can be qualified by a namespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. selectors-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants