Skip to content

[css-syntax-3][cssom-1] Accept <relative-selector-list> in top-level style rules #8618

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

Closed
cdoublev opened this issue Mar 20, 2023 · 2 comments

Comments

@cdoublev
Copy link
Collaborator

I suspect this has already been discussed before but I cannot find any trace of it.

If I am not mistaken, & is valid in the prelude of a top-level style rule and represents :root. So it is theoretically valid to use a <relative-selector-list> like > body.

Would it be acceptable to define the prelude of top-level style rules with <relative-selector-list> instead of <selector-list>?

If so, changes would be required in CSS Syntax 3 (8.1. Defining Block Contents: the <declaration-list>, <rule-list>, and <stylesheet> productions) and CSSOM (parse a selector and serialize a selector).


Obviously, that does not seem usefull. I am actually interested in having a single style rule definition to simplify the representation of CSS rule definitions.

The block value of @scope is defined with <stylesheet>, which accepts all CSS rules except those excluded by @scope or restricted to a specific context (eg. keyframe, margin, etc).

For all other CSS rules whose block value is <stylesheet>, this is equivalent to accepting all top-level rules excluding @import and @namespace.

But the prelude of (scoped) style rules in @scope is defined with <relative-selector-list> (like nested style rules) therefore valid rules in @scope need to be explicitly defined rather than defining a list of excluded rules, which is otherwise matching the intent of the formal definition of <stylesheet> in CSS Syntax 3 (emphasize added):

For rules that use <stylesheet>, all rules are allowed by default, but the spec for the rule may define what types of rules are invalid inside the rule.

the <stylesheet> production represents a list of rules. It is identical to , except that blocks using it default to accepting all rules that aren’t otherwise limited to a particular context.

https://drafts.csswg.org/css-syntax-3/#declaration-rule-list

@romainmenke
Copy link
Member

This was previously discussed here : #8010
But that was more from an author perspective.

@cdoublev
Copy link
Collaborator Author

Ah, I knew it, but failed to find it... Thanks. and I agree with your opinion/decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants