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

Fix issue #166 #167

Merged
merged 1 commit into from
Feb 18, 2019
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
4 changes: 4 additions & 0 deletions __tests__/purgecss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ describe('keyframes', () => {
it('removes flash', () => {
expect(purgecssResult.includes('@keyframes flash')).toBe(false)
})
it('keeps keyframes from animations with multiple keyframes', () => {
expect(purgecssResult.includes('@keyframes scale')).toBe(true)
expect(purgecssResult.includes('@keyframes spin')).toBe(true)
})
})

describe('pseudo selectors', () => {
Expand Down
26 changes: 25 additions & 1 deletion __tests__/test_examples/keyframes/keyframes.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,28 @@

.flash {
animation: flash
}
}

@keyframes scale {
from {
transform: scale(1);
}

to {
transform: scale(2);
}
}

@keyframes spin {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}

.scale-spin {
animation: spin 300ms linear infinite forwards,scale 300ms linear infinite alternate;
}
3 changes: 3 additions & 0 deletions __tests__/test_examples/keyframes/keyframes.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
<div class="bounce">
</div>

<div class="scale-spin">
</div>
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class Purgecss {
for (const { prop, value } of node.nodes) {
if (this.options.keyframes) {
if (prop === 'animation' || prop === 'animation-name') {
for (const word of value.split(' ')) {
for (const word of value.split(/[\s,]+/)) {
this.usedAnimations.add(word)
}
}
Expand Down