Skip to content

Commit 68dbc5f

Browse files
authored
only prefix animation names that are defined (#2641)
1 parent bbacd59 commit 68dbc5f

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

__tests__/plugins/animation.test.js

+41-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,52 @@ test('defining animation and keyframes with prefix', () => {
8080
}
8181
}
8282
}
83-
83+
8484
@layer utilities {
8585
@variants {
8686
.tw-animate-none { animation: none; }
8787
.tw-animate-spin { animation: tw-spin 1s linear infinite; }
8888
.tw-animate-ping { animation: tw-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite; }
8989
}
90-
}
90+
}
91+
`)
92+
})
93+
94+
test('defining animation and keyframes with prefix (skip undefined animations)', () => {
95+
const config = {
96+
prefix: 'tw-',
97+
theme: {
98+
animation: {
99+
none: 'none',
100+
spin: 'spin 1s linear infinite',
101+
ping: 'ping 1s cubic-bezier(0, 0, 0.2, 1) infinite',
102+
},
103+
keyframes: {
104+
spin: { to: { transform: 'rotate(360deg)' } },
105+
},
106+
},
107+
variants: {
108+
animation: [],
109+
},
110+
}
111+
112+
const { utilities } = processPlugins([plugin()], config)
113+
114+
expect(css(utilities)).toMatchCss(`
115+
@layer utilities {
116+
@variants {
117+
@keyframes tw-spin {
118+
to { transform: rotate(360deg); }
119+
}
120+
}
121+
}
122+
123+
@layer utilities {
124+
@variants {
125+
.tw-animate-none { animation: none; }
126+
.tw-animate-spin { animation: tw-spin 1s linear infinite; }
127+
.tw-animate-ping { animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite; }
128+
}
129+
}
91130
`)
92131
})

src/plugins/animation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function () {
1818
_.mapKeys(animationConfig, (_animation, suffix) => nameClass('animate', suffix)),
1919
(animation) => {
2020
const { name } = parseAnimationValue(animation)
21-
if (name === undefined) return { animation }
21+
if (name === undefined || keyframesConfig[name] === undefined) return { animation }
2222
return { animation: animation.replace(name, prefixName(name)) }
2323
}
2424
)

0 commit comments

Comments
 (0)