Skip to content

[css-nesting][selectors] Behavior of & with a default namespace? #9806

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

Open
Loirooriol opened this issue Jan 17, 2024 · 1 comment
Open

[css-nesting][selectors] Behavior of & with a default namespace? #9806

Loirooriol opened this issue Jan 17, 2024 · 1 comment
Labels
css-nesting-1 Current Work selectors-4 Current Work

Comments

@Loirooriol
Copy link
Contributor

Loirooriol commented Jan 17, 2024

https://drafts.csswg.org/selectors/#type-nmsp

If a default namespace is declared, compound selectors without type selectors in them still only match elements in that default namespace.

https://drafts.csswg.org/css-nesting/#nest-selector defines a & selector (which is not a type selector).

Then, consider

@namespace url("http://example.com/foo");
@namespace svg url("http://www.w3.org/2000/svg");
svg|a {
  &:hover {}
}

&:hover has no type selector, so as per Selectors, it won't match a svg|a:hover. That's how Gecko, Blink and WebKit behave.

But I think it's supposed to match to be consistent with what @tabatkins is saying in #5684 and #9804

Possibly, Selectors should say something like

If a default namespace is declared, compound selectors without type selectors nor & selectors in them still only match elements in that default namespace.

@Loirooriol Loirooriol added selectors-4 Current Work css-nesting-1 Current Work labels Jan 17, 2024
@Loirooriol Loirooriol changed the title [css-nesting][css-selectors] Behavior of & with a default namespace? [css-nesting][selectors] Behavior of & with a default namespace? Jan 17, 2024
@tabatkins
Copy link
Member

I agree, & should prevent the default namespace from applying. It falls under the general rule that dbaron describes, as I summarized in #9804 (comment). This would have to be handled via explicit spec text, as it wouldn't be caught by my proposed general rule there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-nesting-1 Current Work selectors-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants