Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape animation names when prefixes contain special characters #11470

Merged
merged 2 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix source maps issue resulting in a crash ([#11319](https://github.com/tailwindlabs/tailwindcss/pull/11319))
- Fallback to RegEx based parser when using custom transformers or extractors ([#11335](https://github.com/tailwindlabs/tailwindcss/pull/11335))
- 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))

### Added

Expand Down
2 changes: 1 addition & 1 deletion src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,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 }]
Expand Down
30 changes: 30 additions & 0 deletions tests/animations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,33 @@ test('with dots in the name and prefix', () => {
`)
})
})

test('special character prefixes are escaped in animation names', () => {
let config = {
prefix: '@',
content: [{ raw: `<div class="@animate-one"></div>` }],
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;
}
`)
})
})