Skip to content

Commit e88956d

Browse files
committed
Escape animation names when prefixes contain special characters (#11470)
* Escape animation names when prefixes contain special characters * Update changelog
1 parent cf9fef4 commit e88956d

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Fix parsing of `theme()` inside `calc()` when there are no spaces around operators ([#11157](https://github.com/tailwindlabs/tailwindcss/pull/11157))
1414
- Ensure `repeating-conic-gradient` is detected as an image ([#11180](https://github.com/tailwindlabs/tailwindcss/pull/11180))
1515
- Move unknown pseudo-elements outside of `:is` by default ([#11345](https://github.com/tailwindlabs/tailwindcss/pull/11345))
16+
- Escape animation names when prefixes contain special characters ([#11470](https://github.com/tailwindlabs/tailwindcss/pull/11470))
1617

1718
## [3.3.2] - 2023-04-25
1819

src/corePlugins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ export let corePlugins = {
913913
},
914914

915915
animation: ({ matchUtilities, theme, config }) => {
916-
let prefixName = (name) => `${config('prefix')}${escapeClassName(name)}`
916+
let prefixName = (name) => escapeClassName(config('prefix') + name)
917917
let keyframes = Object.fromEntries(
918918
Object.entries(theme('keyframes') ?? {}).map(([key, value]) => {
919919
return [key, { [`@keyframes ${prefixName(key)}`]: value }]

tests/animations.test.js

+30
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,33 @@ crosscheck(() => {
276276
})
277277
})
278278
})
279+
280+
test('special character prefixes are escaped in animation names', () => {
281+
let config = {
282+
prefix: '@',
283+
content: [{ raw: `<div class="@animate-one"></div>` }],
284+
theme: {
285+
extend: {
286+
keyframes: {
287+
one: { to: { transform: 'rotate(360deg)' } },
288+
},
289+
animation: {
290+
one: 'one 2s',
291+
},
292+
},
293+
},
294+
}
295+
296+
return run('@tailwind utilities', config).then((result) => {
297+
expect(result.css).toMatchFormattedCss(css`
298+
@keyframes \@one {
299+
to {
300+
transform: rotate(360deg);
301+
}
302+
}
303+
.\@animate-one {
304+
animation: 2s \@one;
305+
}
306+
`)
307+
})
308+
})

0 commit comments

Comments
 (0)