Skip to content

[css-namespaces-3] @layer statement should be valid before @namespace #8658

@cdoublev

Description

@cdoublev

In Cascade 5:

Such empty @layer rules are allowed before @import and @namespace rules

Therefore there is probably an oversight in CSS Namespaces 3:

Any @namespace rules must follow all @charset and @import rules and precede all other non-ignored at-rules and style rules

For @import:

Any @import rules must precede all other valid at-rules and style rules in a style sheet (ignoring @charset and @layer statement rules)

I would suggest:

- Any @namespace rules must follow all @charset and @import rules 
- and precede all other non-ignored at-rules and style rules
+ Any @namespace rules must precede all other non-ignored rules (ignoring @layer statement rules),
+ and must not have any other non-ignored rules between it and previous @import or @namespace rules

Aside: the first line confused me because it suggests that @namespace must be invalid when it does not follow @charset and @import rules, whereas it must remains valid, like any following @charset, only following @import are invalid.

I think the requirements should focus on what makes @namespace invalid, instead of what makes other rules invalid.


I am not sure the following table is appropriate, but a visual summary of the required hierarchy between these rules may be helpful to authors. At least, it is a good memo to me.

Rule 1 Rule 2 Rule 3 Invalid
@layer @import @layer none
@layer @namespace @layer none
@layer @import @namespace none
@import @namespace @layer none
@import @layer @import @import: it must not follow @layer following @import
@import @layer @namespace @namespace: it must not follow @layer following @import
@namespace @layer @namespace @namespace: it must not follow @layer following @namespace
@namespace @layer @import @import: it must not follow @namespace
@namespace @import @layer @import: it must not follow @namespace

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions