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

feat(css/parser): new nesting spec #6337

Merged
merged 13 commits into from Nov 3, 2022
8 changes: 5 additions & 3 deletions crates/swc_css_ast/src/base.rs
Expand Up @@ -4,7 +4,7 @@ use swc_common::{ast_node, EqIgnoreSpan, Span};
use crate::{
AlphaValue, AtRule, CalcSum, CmykComponent, Color, ComplexSelector, DashedIdent, Delimiter,
Dimension, Hue, Ident, Integer, KeyframeBlock, LayerName, Number, Percentage, Ratio,
SelectorList, Str, TokenAndSpan, UnicodeRange, Url,
RelativeSelectorList, SelectorList, Str, TokenAndSpan, UnicodeRange, Url,
};

#[ast_node("Stylesheet")]
Expand Down Expand Up @@ -38,10 +38,12 @@ pub struct QualifiedRule {
#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
pub enum QualifiedRulePrelude {
#[tag("ListOfComponentValues")]
ListOfComponentValues(ListOfComponentValues),
#[tag("SelectorList")]
SelectorList(SelectorList),
#[tag("RelativeSelectorList")]
RelativeSelectorList(RelativeSelectorList),
#[tag("ListOfComponentValues")]
ListOfComponentValues(ListOfComponentValues),
}

#[ast_node]
Expand Down
4 changes: 4 additions & 0 deletions crates/swc_css_codegen/src/lib.rs
Expand Up @@ -93,6 +93,10 @@ where
emit!(self, n);
formatting_space!(self);
}
QualifiedRulePrelude::RelativeSelectorList(n) => {
emit!(self, n);
formatting_space!(self);
}
QualifiedRulePrelude::ListOfComponentValues(n) => {
emit!(
&mut *self.with_ctx(Ctx {
Expand Down
Expand Up @@ -24,8 +24,7 @@
.foo {
color: red;
@media (min-width: 480px) {
& h1,
& h2 {
& h1, & h2 {
color: blue;
}
}
Expand Down
Expand Up @@ -83,8 +83,8 @@ body:first-of-type .selector {}
$property: value;color: red;
}
.selector {
color: red;
&property: value;}
&property: value;color: red;
}
.selector {
*property: value;color: red;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.