Skip to content

Commit

Permalink
Merge pull request #167 from ThisNameWasTaken/master
Browse files Browse the repository at this point in the history
Fix issue #166
  • Loading branch information
Ffloriel authored Feb 18, 2019
2 parents e250219 + b7749a9 commit cde0071
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
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

0 comments on commit cde0071

Please sign in to comment.