Skip to content

Commit

Permalink
fix #2115: support @font-palette-values
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Mar 24, 2022
1 parent 2296f46 commit 6fc8aa8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,22 @@
# Changelog

## Unreleased

* Add support for some new CSS rules ([#2115](https://github.com/evanw/esbuild/issues/2115))

This release adds support for [`@font-palette-values`](https://drafts.csswg.org/css-fonts-4/#font-palette-values):

```css
/* Original code */
@font-palette-values Foo { base-palette: 1; }

/* Old output (with --minify) */
@font-palette-values Foo{base-palette: 1;}

/* New output (with --minify) */
@font-palette-values Foo{base-palette:1}
```

## 0.14.27

* Avoid generating an enumerable `default` import for CommonJS files in Babel mode ([#2097](https://github.com/evanw/esbuild/issues/2097))
Expand Down
3 changes: 3 additions & 0 deletions internal/css_parser/css_parser.go
Expand Up @@ -681,6 +681,9 @@ var specialAtRules = map[string]atRuleKind{

// Reference: https://drafts.csswg.org/css-nesting-1/
"nest": atRuleDeclarations,

// Reference: https://drafts.csswg.org/css-fonts-4/#font-palette-values
"font-palette-values": atRuleDeclarations,
}

type atRuleValidity uint8
Expand Down
17 changes: 17 additions & 0 deletions internal/css_parser/css_parser_test.go
Expand Up @@ -849,6 +849,23 @@ func TestAtRule(t *testing.T) {
content: "rb";
}
}
`)

// https://drafts.csswg.org/css-fonts-4/#font-palette-values
expectPrinted(t, `
@font-palette-values Augusta {

This comment has been minimized.

Copy link
@yisibl

yisibl Mar 27, 2022

Contributor

The syntax here should be starting with --, otherwise it should report an error.

@font-palette-values <dashed-ident>

Maybe we should implement a new type, e.g. atRuleDashedIdentDeclarations

This comment has been minimized.

Copy link
@evanw

evanw Mar 28, 2022

Author Owner

This text was lifted directly from the specification. It's "EXAMPLE 80" on https://drafts.csswg.org/css-fonts-4/#example-1d6dc3cd. In any case, esbuild generally takes a "garbage in, garbage out" approach to CSS. You should be using a CSS linter to ensure that you're using CSS correctly.

This comment has been minimized.

Copy link
@yisibl

yisibl Mar 28, 2022

Contributor

I will submit a patch to the spec.

This comment has been minimized.

Copy link
@yisibl

yisibl Mar 29, 2022

Contributor

Specifications have been updated: w3c/csswg-drafts#7168

font-family: Handover Sans;
base-palette: 3;
override-colors: 1 rgb(43, 12, 9), 2 #000, 3 var(--highlight)
}
`, `@font-palette-values Augusta {
font-family: Handover Sans;
base-palette: 3;
override-colors:
1 rgb(43, 12, 9),
2 #000,
3 var(--highlight);
}
`)
}

Expand Down

0 comments on commit 6fc8aa8

Please sign in to comment.