diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c36eeca3d18..bc8ae0539dbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix parsing of `theme()` inside `calc()` when there are no spaces around operators ([#11157](https://github.com/tailwindlabs/tailwindcss/pull/11157)) - Ensure `repeating-conic-gradient` is detected as an image ([#11180](https://github.com/tailwindlabs/tailwindcss/pull/11180)) - Move unknown pseudo-elements outside of `:is` by default ([#11345](https://github.com/tailwindlabs/tailwindcss/pull/11345)) +- Escape animation names when prefixes contain special characters ([#11470](https://github.com/tailwindlabs/tailwindcss/pull/11470)) ## [3.3.2] - 2023-04-25 diff --git a/src/corePlugins.js b/src/corePlugins.js index e4d2ff279a30..606cfd7bbecf 100644 --- a/src/corePlugins.js +++ b/src/corePlugins.js @@ -913,7 +913,7 @@ export let corePlugins = { }, animation: ({ matchUtilities, theme, config }) => { - let prefixName = (name) => `${config('prefix')}${escapeClassName(name)}` + let prefixName = (name) => escapeClassName(config('prefix') + name) let keyframes = Object.fromEntries( Object.entries(theme('keyframes') ?? {}).map(([key, value]) => { return [key, { [`@keyframes ${prefixName(key)}`]: value }] diff --git a/tests/animations.test.js b/tests/animations.test.js index 958f24252fdc..b8d0d2406306 100644 --- a/tests/animations.test.js +++ b/tests/animations.test.js @@ -276,3 +276,33 @@ crosscheck(() => { }) }) }) + +test('special character prefixes are escaped in animation names', () => { + let config = { + prefix: '@', + content: [{ raw: `
` }], + theme: { + extend: { + keyframes: { + one: { to: { transform: 'rotate(360deg)' } }, + }, + animation: { + one: 'one 2s', + }, + }, + }, + } + + return run('@tailwind utilities', config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + @keyframes \@one { + to { + transform: rotate(360deg); + } + } + .\@animate-one { + animation: 2s \@one; + } + `) + }) +})