Skip to content

Commit 9b13226

Browse files
authoredSep 23, 2020
Don't escape keyframes (#2432)
* Don't escape keyframes * Update changelog
1 parent 0221f2f commit 9b13226

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed
 

‎CHANGELOG.md

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

88
## [Unreleased]
99

10-
- Nothing yet!
10+
- Don't escape keyframe values ([#2432](https://github.com/tailwindlabs/tailwindcss/pull/2432))
1111

1212
## [1.8.10] - 2020-09-14
1313

‎__tests__/processPlugins.test.js

+47
Original file line numberDiff line numberDiff line change
@@ -2003,3 +2003,50 @@ test('plugins can extend variants', () => {
20032003
expect(result.css).toMatchCss(expected)
20042004
})
20052005
})
2006+
2007+
test('keyframes are not escaped', () => {
2008+
const { components, utilities } = processPlugins(
2009+
[
2010+
function({ addUtilities, addComponents }) {
2011+
addComponents({
2012+
'@keyframes foo': {
2013+
'25.001%': {
2014+
color: 'black',
2015+
},
2016+
},
2017+
})
2018+
addUtilities({
2019+
'@keyframes bar': {
2020+
'75.001%': {
2021+
color: 'white',
2022+
},
2023+
},
2024+
})
2025+
},
2026+
],
2027+
makeConfig()
2028+
)
2029+
2030+
expect(css(components)).toMatchCss(`
2031+
@layer components {
2032+
@variants {
2033+
@keyframes foo {
2034+
25.001% {
2035+
color: black
2036+
}
2037+
}
2038+
}
2039+
}
2040+
`)
2041+
expect(css(utilities)).toMatchCss(`
2042+
@layer utilities {
2043+
@variants {
2044+
@keyframes bar {
2045+
75.001% {
2046+
color: white
2047+
}
2048+
}
2049+
}
2050+
}
2051+
`)
2052+
})

‎src/util/processPlugins.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ function wrapWithLayer(rules, layer) {
2727
.append(cloneNodes(Array.isArray(rules) ? rules : [rules]))
2828
}
2929

30+
function isKeyframeRule(rule) {
31+
return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name)
32+
}
33+
3034
export default function(plugins, config) {
3135
const pluginBaseStyles = []
3236
const pluginComponents = []
@@ -88,7 +92,7 @@ export default function(plugins, config) {
8892
const styles = postcss.root({ nodes: parseStyles(utilities) })
8993

9094
styles.walkRules(rule => {
91-
if (options.respectPrefix) {
95+
if (options.respectPrefix && !isKeyframeRule(rule)) {
9296
rule.selector = applyConfiguredPrefix(rule.selector)
9397
}
9498

@@ -114,7 +118,7 @@ export default function(plugins, config) {
114118
const styles = postcss.root({ nodes: parseStyles(components) })
115119

116120
styles.walkRules(rule => {
117-
if (options.respectPrefix) {
121+
if (options.respectPrefix && !isKeyframeRule(rule)) {
118122
rule.selector = applyConfiguredPrefix(rule.selector)
119123
}
120124
})

0 commit comments

Comments
 (0)