Skip to content

Commit

Permalink
fix #3265: allow whitespace inside of :is()
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jul 22, 2023
1 parent d514ba7 commit d645903
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

* Fix a regression with whitespace inside `:is()` ([#3265](https://github.com/evanw/esbuild/issues/3265))

The change to parse the contents of `:is()` in version 0.18.14 introduced a regression that incorrectly flagged the contents as a syntax error if the contents started with a whitespace token (for example `div:is( .foo ) {}`). This regression has been fixed.

## 0.18.15

* Add the `--serve-fallback=` option ([#2904](https://github.com/evanw/esbuild/issues/2904))
Expand Down
1 change: 1 addition & 0 deletions internal/css_parser/css_parser_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ func (p *parser) parsePseudoClassSelector(isElement bool) css_ast.SS {
}
if ok {
old := p.index
p.eat(css_lexer.TWhitespace)

// ":local" forces local names and ":global" forces global names
oldLocal := p.makeLocalSymbols
Expand Down
4 changes: 4 additions & 0 deletions internal/css_parser/css_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ func TestSelector(t *testing.T) {
expectPrinted(t, "a:b(:c) {}", "a:b(:c) {\n}\n", "")
expectPrinted(t, "a: b {}", "a: b {\n}\n", "<stdin>: WARNING: Expected identifier but found whitespace\n")
expectPrinted(t, ":is(a)b {}", ":is(a)b {\n}\n", "<stdin>: WARNING: Unexpected \"b\"\n")
expectPrinted(t, "a:b( c ) {}", "a:b(c) {\n}\n", "")
expectPrinted(t, "a:b( c , d ) {}", "a:b(c, d) {\n}\n", "")
expectPrinted(t, "a:is( c ) {}", "a:is(c) {\n}\n", "")
expectPrinted(t, "a:is( c , d ) {}", "a:is(c, d) {\n}\n", "")

// These test cases previously caused a hang (see https://github.com/evanw/esbuild/issues/2276)
expectPrinted(t, ":x(", ":x() {\n}\n", "<stdin>: WARNING: Unexpected end of file\n")
Expand Down

0 comments on commit d645903

Please sign in to comment.