Skip to content

Commit

Permalink
formatting support for @position-try (for #3773)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed May 24, 2024
1 parent 5069410 commit d7a8bf3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
}
```

* Formatting support for the `@position-try` rule ([#3773](https://github.com/evanw/esbuild/issues/3773))

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.

## 0.21.3

* Implement the decorator metadata proposal ([#3760](https://github.com/evanw/esbuild/issues/3760))
Expand Down
4 changes: 4 additions & 0 deletions internal/css_parser/css_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,10 @@ var specialAtRules = map[string]atRuleKind{
// Defining before-change style: the @starting-style rule
// Reference: https://drafts.csswg.org/css-transitions-2/#defining-before-change-style-the-starting-style-rule
"starting-style": atRuleInheritContext,

// Anchor Positioning
// Reference: https://drafts.csswg.org/css-anchor-position-1/#at-ruledef-position-try
"position-try": atRuleDeclarations,
}

var atKnownRuleCanBeRemovedIfEmpty = map[string]bool{
Expand Down
8 changes: 8 additions & 0 deletions internal/css_parser/css_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,14 @@ func TestAtRule(t *testing.T) {
}
}
`, "")

// https://drafts.csswg.org/css-anchor-position-1/#at-ruledef-position-try
expectPrinted(t, `@position-try --foo { top: 0 }`,
`@position-try --foo {
top: 0;
}
`, "")
expectPrintedMinify(t, `@position-try --foo { top: 0; }`, `@position-try --foo{top:0}`, "")
}

func TestAtCharset(t *testing.T) {
Expand Down

0 comments on commit d7a8bf3

Please sign in to comment.