Skip to content

Commit 9545822

Browse files
committed
1 parent dc5e750 commit 9545822

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
* Add support for the new [`revert-rule`](https://drafts.csswg.org/css-cascade-5/#revert-rule-keyword) CSS-wide keyword ([#4312](https://github.com/evanw/esbuild/pull/4312))
4+
5+
The `revert-rule` keyword can be combined with `if()` to conditionally ignore a declaration:
6+
7+
```css
8+
div {
9+
color: black;
10+
}
11+
.apply-sharp {
12+
color: if(style(--theme: dark): white; else: revert-rule);
13+
}
14+
```
15+
16+
This was contributed by [@yisibl](https://github.com/yisibl).
17+
318
* Add support for the new `@view-transition` CSS at rule ([#4313](https://github.com/evanw/esbuild/pull/4313))
419

520
```css

internal/css_parser/css_decls_font_family.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var cssWideAndReservedKeywords = map[string]bool{
3131
// CSS Cascading and Inheritance Level 5: https://drafts.csswg.org/css-cascade-5/#defaulting-keywords
3232
"revert": true, // Cascade-dependent keyword
3333
"revert-layer": true, // Cascade-dependent keyword
34+
"revert-rule": true, // Cascade-dependent keyword
3435
}
3536

3637
// Font family names that happen to be the same as a keyword value must be

internal/css_parser/css_parser_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,16 @@ func TestAnimationName(t *testing.T) {
17491749
expectPrinted(t, "div { animation: 2s linear 'name 2', 3s infinite 'name 3' }", "div {\n animation: 2s linear name\\ 2, 3s infinite name\\ 3;\n}\n", "")
17501750
}
17511751

1752+
func TestCSSWideKeywords(t *testing.T) {
1753+
expectPrinted(t, "div { color: inherit; }", "div {\n color: inherit;\n}\n", "")
1754+
expectPrinted(t, "div { color: initial; }", "div {\n color: initial;\n}\n", "")
1755+
expectPrinted(t, "div { color: unset; }", "div {\n color: unset;\n}\n", "")
1756+
expectPrinted(t, "div { color: revert; }", "div {\n color: revert;\n}\n", "")
1757+
expectPrinted(t, "div { color: revert-layer; }", "div {\n color: revert-layer;\n}\n", "")
1758+
expectPrinted(t, "div { color: revert-rule; }", "div {\n color: revert-rule;\n}\n", "")
1759+
expectPrinted(t, "div { color: if(style(--theme: dark): white; else: revert-rule) }", "div {\n color: if(style(--theme: dark): white; else: revert-rule);\n}\n", "")
1760+
}
1761+
17521762
func TestAtRuleValidation(t *testing.T) {
17531763
expectPrinted(t, "a {} b {} c {} @charset \"UTF-8\";", "a {\n}\nb {\n}\nc {\n}\n@charset \"UTF-8\";\n",
17541764
"<stdin>: WARNING: \"@charset\" must be the first rule in the file\n"+
@@ -2706,6 +2716,7 @@ func TestFontFamily(t *testing.T) {
27062716
expectPrintedMangleMinify(t, "a {font-family: 'unset', serif;}", "a{font-family:\"unset\",serif}", "")
27072717
expectPrintedMangleMinify(t, "a {font-family: 'revert', serif;}", "a{font-family:\"revert\",serif}", "")
27082718
expectPrintedMangleMinify(t, "a {font-family: 'revert-layer', 'Segoe UI', serif;}", "a{font-family:\"revert-layer\",Segoe UI,serif}", "")
2719+
expectPrintedMangleMinify(t, "a {font-family: 'revert-rule', 'Segoe UI', serif;}", "a{font-family:\"revert-rule\",Segoe UI,serif}", "")
27092720
expectPrintedMangleMinify(t, "a {font-family: 'default', serif;}", "a{font-family:\"default\",serif}", "")
27102721
}
27112722

0 commit comments

Comments
 (0)