Skip to content

[css-nesting-1][css-cascade-6] Conflicting definitions of nested/scoped style rules and the nesting selector #13517

@cdoublev

Description

@cdoublev

CSS Nesting states the following about the contents of nested group rules:

  • Style rules are nested style rules, with their nesting selector taking its definition from the nearest ancestor style rule.

But CSS Cascade 6 states that style rules in @scope are scoped style rules, with their nesting selector taking its definition from it:

  • The style rules in an @scope <rule-list> are scoped style rules.
  • The & selector is defined to behave as :where(:scope).

I think that nested style rule and scoped style rule are exclusive, since a scoped style rule may not have an ancestor style rule.

I think it may be appropriate to append "unless the nested group rule is @scope, in which case it is a scoped style rule", in the CSS Nesting definition.

CSS Nesting also states:

When the @scope rule is a nested group rule, an & in the <scope-start> selector refers to the elements matched by the nearest ancestor style rule.

While CSS Cascade 6 states:

Any :scope or & selectors in <scope-start> are interpreted as defined for its outer context.

And if the closest outer context is @scope, then it is defined by CSS Cascade 6 as :where(:scope) (see the first quote above), instead of the elements matched by the nearest ancestor style rule.

I think it may be appropriate to append "unless there is a closer @scope, in which case it behaves like :where(:scope)", in the CSS Nesting definition, as stated in its non-normative note.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions