Re: [csswg-drafts] [selectors-4] Allow * before a type selector (#8253)

> A lot (probably most) of selectors in real-world websites don't start with a tag name, they start with a class, pseudo-class, or ID selector and therefore don't need a prefix.

Right, I'm poking in here to try and find a generally-usable, very short way to write selectors starting with type selectors unambiguously (rather than the current "wrap it in an `:is()` suggestion). All the rest of selectors are already unambiguous.

> It can mean "any element that is a div", in the way that *.foo means "any element with 'foo' class."

Right. Currently `*` is defined to be a wildcard tagname selector, but that doesn't necessarily have to be the case. It can just be a wildcard selector in general. Or we can just say that `*` is an optional part of the tagname selector syntax; you can omit either the `*` or the tagname, or leave them both in. Multiple reasonable ways to interpret it.

(I'd forgotten that namespaces exist; being able to write `svg|*` does suggest it's a tagname selector, or at least something very close to it.)

> Putting * in front of * (i.e. **) is not valid.

I'm happy to bite the bullet that my statement "you can put `*` in front of anything" naturally excludes things that already start with `*`. ^_^ (I'm not trying to imagine something that a machine can blindly spam in front of every selector; combinators would also fail the "put a `*` in front of it" rule then. I just want a short, easy way to write the one problematic case.)

> Putting * in front of |div (i.e. *|div) changes the meaning.

You're right, that does violate my general statement. Luckily it's not an issue since `|div` already goes down the selector path due to starting with a symbol. (Plus it's an incredibly niche case (explicitly needing to select a null-namespace element when there's a namespaced element with the same local name also on the page) of an incredibly niche case (caring about namespaces at all). Multiple nines of authors will never even get near this.)

> Is it really worth it to add `*div` when we already have `*|div`?

Maybe not, I'd just forgotten about namespaces existing entirely. Tho starting a selector with `foo|div` would still be problematic.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8253#issuecomment-1366879802 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 28 December 2022 19:45:37 UTC