Skip to content
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

[CSS] Relaxed Nesting Support #3898

Merged
merged 4 commits into from
Feb 18, 2024

Conversation

deathaxe
Copy link
Collaborator

Resolves #3897

This commit implements relaxed syntax for nested style rules according to https://www.w3.org/TR/css-nesting-1/#nested-style-rule.

In general it means, nested selectors of nested style rules no longer need to start with & operator to denote html tags.

The implementation adopts properties-or-selectors context from Less syntax to achieve reliable distinction between declarations and selectors without loosing support for interpolation.

This commit implements relaxed syntax for nested style rules 
according to https://www.w3.org/TR/css-nesting-1/#nested-style-rule.

In general it means, nested selectors of nested style rules no longer need to
start with `&` operator to denote html tags.

The implementation adopts `properties-or-selectors` context from Less syntax
to achieve reliable distinction between declarations and selectors without
loosing support for interpolation.
This commit renames `style-block` contexts to `stylesheet-block` in order to
avoid confusion with official syntax specs, because a `style-block` is actually
what is represented by `property-lists` contexts in this syntax definition.

A stylesheet block's content is however equal to top-level content, which does
not support declarations (property-value pairs).
@deathaxe deathaxe marked this pull request as ready for review December 29, 2023 19:37
@deathaxe
Copy link
Collaborator Author

It appears SCSS and Less are becoming obsolete.

@michaelblyons michaelblyons changed the title [CSS] Relexed Nesting Support [CSS] Relaxed Nesting Support Dec 30, 2023
@deathaxe
Copy link
Collaborator Author

deathaxe commented Feb 9, 2024

Note that lazy nesting is supported by all major browsers.

@jrappen
Copy link
Contributor

jrappen commented Feb 14, 2024

Thanks, appreciate the work on this.

@deathaxe deathaxe merged commit b4decd9 into sublimehq:master Feb 18, 2024
2 checks passed
@deathaxe deathaxe deleted the pr/css/relaxed-nesting branch February 18, 2024 07:30
@deathaxe
Copy link
Collaborator Author

Thanks for reviewing.

deathaxe added a commit to SublimeText/Less that referenced this pull request Feb 24, 2024
As of ST4149 `&` is part of selector_start in CSS and doesn't need to be
explicitly added by Less.

Variable `selector_begin` is maintained only for backward compatibility
with some unreleased revisions of core CSS.

Variable `property_or_selector_begin` as adjusted to match CSS
(as of sublimehq/Packages#3898) and is maintained
for backward compatibility with ST builds which do not ship that PR.
@ryami333
Copy link

How is this fix distributed - does it come bundled in a mainstream Sublime build, or will this be published independently to the Sublime package registry sooner than that?

@michaelblyons
Copy link
Collaborator

does it come bundled in a mainstream Sublime build,

Yes, eventually.

will this be published independently to the Sublime package registry sooner than that?

No, but you can get it early with the README instructions, or I think jfcherng has a script to get the latest master from here.

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

Successfully merging this pull request may close these issues.

[CSS] Relaxed Nesting Support
6 participants