Skip to content

Commit

Permalink
Fix candidate extractor regression (#8558)
Browse files Browse the repository at this point in the history
* fix regression

This is a regression where `%>utility<%` didn't properly abstract
`utility`

* update changelog
  • Loading branch information
RobinMalfait committed Jun 9, 2022
1 parent c01ce5c commit 9a5db88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Fix candidate extractor regression ([#8558](https://github.com/tailwindlabs/tailwindcss/pull/8558))

## [3.1.0] - 2022-06-08

Expand Down
4 changes: 2 additions & 2 deletions src/lib/defaultExtractor.js
Expand Up @@ -43,7 +43,7 @@ function* buildRegExps(context) {
/(?![{([]])/,

// optionally followed by an opacity modifier
/(?:\/[^\s'"\\$]*)?/,
/(?:\/[^\s'"\\><$]*)?/,
]),

regex.pattern([
Expand All @@ -58,7 +58,7 @@ function* buildRegExps(context) {
]),

// Normal values w/o quotes — may include an opacity modifier
/[-\/][^\s'"\\$={]*/,
/[-\/][^\s'"\\$={><]*/,
])
),
]),
Expand Down
11 changes: 11 additions & 0 deletions tests/default-extractor.test.js
Expand Up @@ -438,3 +438,14 @@ test('with double quotes array within function', async () => {
expect(extractions).toContain('pl-1.5')
expect(extractions).not.toContain('pl-1')
})

test('with angle brackets', async () => {
const extractions = defaultExtractor(
`<div class="bg-blue-200 <% if (useShadow) { %>shadow-xl<% } %>">test</div>`
)

expect(extractions).toContain('bg-blue-200')
expect(extractions).toContain('shadow-xl')
expect(extractions).not.toContain('>shadow-xl')
expect(extractions).not.toContain('shadow-xl<')
})

0 comments on commit 9a5db88

Please sign in to comment.