Skip to content

Commit d7a8bf3

Browse files
committed
formatting support for @position-try (for #3773)
1 parent 5069410 commit d7a8bf3

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
}
7878
```
7979
80+
* Formatting support for the `@position-try` rule ([#3773](https://github.com/evanw/esbuild/issues/3773))
81+
82+
Chrome shipped this new CSS at-rule in version 125 as part of the [CSS anchor positioning API](https://developer.chrome.com/blog/anchor-positioning-api). With this release, esbuild now knows to expect a declaration list inside of the `@position-try` body block and will format it appropriately.
83+
8084
## 0.21.3
8185
8286
* Implement the decorator metadata proposal ([#3760](https://github.com/evanw/esbuild/issues/3760))

internal/css_parser/css_parser.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,10 @@ var specialAtRules = map[string]atRuleKind{
11021102
// Defining before-change style: the @starting-style rule
11031103
// Reference: https://drafts.csswg.org/css-transitions-2/#defining-before-change-style-the-starting-style-rule
11041104
"starting-style": atRuleInheritContext,
1105+
1106+
// Anchor Positioning
1107+
// Reference: https://drafts.csswg.org/css-anchor-position-1/#at-ruledef-position-try
1108+
"position-try": atRuleDeclarations,
11051109
}
11061110

11071111
var atKnownRuleCanBeRemovedIfEmpty = map[string]bool{

internal/css_parser/css_parser_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,14 @@ func TestAtRule(t *testing.T) {
15391539
}
15401540
}
15411541
`, "")
1542+
1543+
// https://drafts.csswg.org/css-anchor-position-1/#at-ruledef-position-try
1544+
expectPrinted(t, `@position-try --foo { top: 0 }`,
1545+
`@position-try --foo {
1546+
top: 0;
1547+
}
1548+
`, "")
1549+
expectPrintedMinify(t, `@position-try --foo { top: 0; }`, `@position-try --foo{top:0}`, "")
15421550
}
15431551

15441552
func TestAtCharset(t *testing.T) {

0 commit comments

Comments
 (0)