Skip to content

Commit b341813

Browse files
authored
Ensure we can use < and > characters in modifiers (#6851)
* ensure we can use "special" characters in modifiers Fixes: #6778 * update changelog
1 parent 875c850 commit b341813

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Improve `DEBUG` flag ([#6797](https://github.com/tailwindlabs/tailwindcss/pull/6797), [#6804](https://github.com/tailwindlabs/tailwindcss/pull/6804))
13+
- Ensure we can use `<` and `>` characters in modifiers ([#6851](https://github.com/tailwindlabs/tailwindcss/pull/6851))
1314

1415
## [3.0.8] - 2021-12-28
1516

src/lib/defaultExtractor.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const PATTERNS = [
1313
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source, // `[content:'hello']` but not `[content:"hello"]`
1414
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source, // `[content:"hello"]` but not `[content:'hello']`
1515
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source, // `fill-[#bada55]`, `fill-[#bada55]/50`
16+
/([^"'`\s]*[^<>"'`\s:\\])/.source, // `<sm:underline`, `md>:font-bold`
1617
/([^<>"'`\s]*[^"'`\s:\\])/.source, // `px-1.5`, `uppercase` but not `uppercase:`
1718

1819
// Arbitrary properties

tests/default-extractor.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,12 @@ test('arbitrary values with angle brackets in double quotes', async () => {
323323
expect(extractions).toContain(`hover:content-["<"]`)
324324
expect(extractions).toContain(`hover:focus:content-[">"]`)
325325
})
326+
327+
test('special characters', async () => {
328+
const extractions = defaultExtractor(`
329+
<div class="<sm:underline md>:font-bold"></div>
330+
`)
331+
332+
expect(extractions).toContain(`<sm:underline`)
333+
expect(extractions).toContain(`md>:font-bold`)
334+
})

tests/variants.test.js

+22
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,25 @@ it('should not generate variants of user css if it is not inside a layer', () =>
445445
`)
446446
})
447447
})
448+
449+
it('should be possible to use responsive modifiers that are defined with special characters', () => {
450+
let config = {
451+
content: [{ raw: html`<div class="<sm:underline"></div>` }],
452+
theme: {
453+
screens: {
454+
'<sm': { max: '399px' },
455+
},
456+
},
457+
plugins: [],
458+
}
459+
460+
return run('@tailwind utilities', config).then((result) => {
461+
return expect(result.css).toMatchFormattedCss(css`
462+
@media (max-width: 399px) {
463+
.\<sm\:underline {
464+
text-decoration-line: underline;
465+
}
466+
}
467+
`)
468+
})
469+
})

0 commit comments

Comments
 (0)