Skip to content

Commit

Permalink
Improve jsx interpolation candidate matching (#6593)
Browse files Browse the repository at this point in the history
* ensure that strangely used jsx with interpolation gets detected

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* update changelog

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
  • Loading branch information
3 people committed Dec 17, 2021
1 parent 27c67fe commit 9e03a68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improve circular dependency detection when using `@apply` ([#6588](https://github.com/tailwindlabs/tailwindcss/pull/6588))
- Only generate variants for non-`user` layers ([#6589](https://github.com/tailwindlabs/tailwindcss/pull/6589))
- Properly extract classes with arbitrary values in arrays and classes followed by escaped quotes ([#6590](https://github.com/tailwindlabs/tailwindcss/pull/6590))
- Improve jsx interpolation candidate matching ([#6593](https://github.com/tailwindlabs/tailwindcss/pull/6593))

## [3.0.6] - 2021-12-16

Expand Down
2 changes: 1 addition & 1 deletion src/lib/defaultExtractor.js
Expand Up @@ -17,7 +17,7 @@ const PATTERNS = [
].join('|')

const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g')
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%$]*[^<>"'`\s.(){}[\]#=%:$]/g

/**
* @param {string} content
Expand Down
7 changes: 5 additions & 2 deletions tests/default-extractor.test.js
@@ -1,7 +1,9 @@
import { html } from './util/run'
import { defaultExtractor } from '../src/lib/defaultExtractor'

const input = html`
let jsxExample = "<div className={`overflow-scroll${conditionIsOpen ? '' : ' hidden'}`}></div>"
const input =
html`
<div class="font-['some_font',sans-serif]"></div>
<div class='font-["some_font",sans-serif]'></div>
<div class="bg-[url('...')]"></div>
Expand Down Expand Up @@ -44,7 +46,7 @@ const input = html`
uppercase:true
}
</script>
`
` + jsxExample

const includes = [
`font-['some_font',sans-serif]`,
Expand Down Expand Up @@ -84,6 +86,7 @@ const includes = [
`lg:text-[24px]`,
`content-['>']`,
`hover:test`,
`overflow-scroll`,
]

const excludes = [
Expand Down

0 comments on commit 9e03a68

Please sign in to comment.