Skip to content

Commit

Permalink
Fix matching first nested class name
Browse files Browse the repository at this point in the history
For example in a @media block.
  • Loading branch information
airblade committed Mar 21, 2023
1 parent de9bcca commit f1b1c30
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tcs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Tcs
CLASS_NAME = /
[\A^},\s]
[\A^{},\s]
[.]
(
[-_a-zA-Z][^\s,{}]+
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
}

.cat{color:red;}.dog{color:red;}.rabbit{width:2.5rem;}.hamster{margin:0.5px}

@media(min-width: 640px){.sm\:grid-cols-3{grid-template-columns:repeat(3, minmax(0, 1fr));}
2 changes: 1 addition & 1 deletion test/tcs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_extract_classes
load_tcs

css = File.read(File.expand_path('fixtures/styles.css', __dir__))
assert_equal %w[ foo bar baz quz cat dog rabbit hamster ],
assert_equal %w[ foo bar baz quz cat dog rabbit hamster sm\\:grid-cols-3 ],
Tcs.send(:extract_class_names, css)
end

Expand Down

0 comments on commit f1b1c30

Please sign in to comment.