Skip to content

Commit

Permalink
fix #1397: support "s" in css attribute selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 27, 2021
1 parent 80c92d4 commit a7e007c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

The `translate3d` to `translateZ` conversion was contributed by [@steambap](https://github.com/steambap).

* Support for the case-sensitive flag in CSS attribute selectors ([#1397](https://github.com/evanw/esbuild/issues/1397))

You can now use the case-sensitive CSS attribute selector flag `s` such as in `[type="a" s] { list-style: lower-alpha; }`. Previously doing this caused a warning about unrecognized syntax.

## 0.12.9

* Allow `this` with `--define` ([#1361](https://github.com/evanw/esbuild/issues/1361))
Expand Down
2 changes: 1 addition & 1 deletion internal/css_parser/css_parser_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (p *parser) parseAttributeSelector() (attr css_ast.SSAttribute, ok bool) {
p.eat(css_lexer.TWhitespace)
if p.peek(css_lexer.TIdent) {
if modifier := p.decoded(); len(modifier) == 1 {
if c := modifier[0]; c == 'i' || c == 'I' {
if c := modifier[0]; c == 'i' || c == 'I' || c == 's' || c == 'S' {
attr.MatcherModifier = c
p.advance()
}
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 @@ -614,8 +614,12 @@ func TestSelector(t *testing.T) {

expectPrinted(t, "[b = \"c\" i] {}", "[b=c i] {\n}\n")
expectPrinted(t, "[b = \"c\" I] {}", "[b=c I] {\n}\n")
expectPrinted(t, "[b = \"c\" s] {}", "[b=c s] {\n}\n")
expectPrinted(t, "[b = \"c\" S] {}", "[b=c S] {\n}\n")
expectParseError(t, "[b i] {}", "<stdin>: warning: Expected \"]\" but found \"i\"\n<stdin>: warning: Unexpected \"]\"\n")
expectParseError(t, "[b I] {}", "<stdin>: warning: Expected \"]\" but found \"I\"\n<stdin>: warning: Unexpected \"]\"\n")
expectParseError(t, "[b s] {}", "<stdin>: warning: Expected \"]\" but found \"s\"\n<stdin>: warning: Unexpected \"]\"\n")
expectParseError(t, "[b S] {}", "<stdin>: warning: Expected \"]\" but found \"S\"\n<stdin>: warning: Unexpected \"]\"\n")

expectPrinted(t, "|b {}", "|b {\n}\n")
expectPrinted(t, "|* {}", "|* {\n}\n")
Expand Down

0 comments on commit a7e007c

Please sign in to comment.