-
-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(css_parser): fix CSS multiple ampersand support (#3367)
- Loading branch information
1 parent
f2b49c0
commit f6ca506
Showing
115 changed files
with
3,691 additions
and
2,707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
crates/biome_css_formatter/src/css/lists/nested_selector_list.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssNestedSelectorList; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssNestedSelectorList; | ||
impl FormatRule<CssNestedSelectorList> for FormatCssNestedSelectorList { | ||
type Context = CssFormatContext; | ||
fn fmt(&self, node: &CssNestedSelectorList, f: &mut CssFormatter) -> FormatResult<()> { | ||
f.join().entries(node.iter().formatted()).finish() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
crates/biome_css_formatter/src/css/selectors/nested_selector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::{CssNestedSelector, CssNestedSelectorFields}; | ||
use biome_formatter::write; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssNestedSelector; | ||
impl FormatNodeRule<CssNestedSelector> for FormatCssNestedSelector { | ||
fn fmt_fields(&self, node: &CssNestedSelector, f: &mut CssFormatter) -> FormatResult<()> { | ||
let CssNestedSelectorFields { amp_token } = node.as_fields(); | ||
write!(f, [amp_token.format()]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
crates/biome_css_formatter/tests/specs/css/nesting/nesting_1.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.test { | ||
& { | ||
color: pink; | ||
} | ||
&& { | ||
color: pink; | ||
} | ||
& & { | ||
color: pink; | ||
} | ||
div { | ||
&&& { | ||
color: pink; | ||
} | ||
& && { | ||
color: pink; | ||
} | ||
&& & { | ||
color: pink; | ||
} | ||
& & & { | ||
color: pink; | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
crates/biome_css_formatter/tests/specs/css/nesting/nesting_1.css.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: css/nesting/nesting_1.css | ||
--- | ||
# Input | ||
|
||
```css | ||
.test { | ||
& { | ||
color: pink; | ||
} | ||
&& { | ||
color: pink; | ||
} | ||
& & { | ||
color: pink; | ||
} | ||
div { | ||
&&& { | ||
color: pink; | ||
} | ||
& && { | ||
color: pink; | ||
} | ||
&& & { | ||
color: pink; | ||
} | ||
& & & { | ||
color: pink; | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
----- | ||
|
||
```css | ||
.test { | ||
& { | ||
color: pink; | ||
} | ||
&& { | ||
color: pink; | ||
} | ||
& & { | ||
color: pink; | ||
} | ||
div { | ||
&&& { | ||
color: pink; | ||
} | ||
& && { | ||
color: pink; | ||
} | ||
&& & { | ||
color: pink; | ||
} | ||
& & & { | ||
color: pink; | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.