Skip to content

Commit

Permalink
Merge pull request #69 from FullHuman/bugfix/keyframes_float_values
Browse files Browse the repository at this point in the history
Don't delete keyframe animations with floats
  • Loading branch information
Ffloriel authored Mar 20, 2018
2 parents a68f374 + 61db19c commit be5ac0f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions __tests__/purgecssDefault.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,36 @@ describe('purge methods with files and default extractor', () => {
expect(purgecssResult.includes(`src: url('xxx')`)).toBe(false)
})
})

describe('keep keyframe decimals', () => {
let purgecssResult
beforeAll(() => {
purgecssResult = new Purgecss({
content: [
{
raw: '<div class="xx"></div>',
extension: 'html'
}
],
css: [
{
raw: `
@keyframes xxx {
0% {opacity: 0;}
99.9% {opacity: 1;}
}
.xx { animation: xxx 200ms linear both }
`
}
],
keyframes: false
}).purge()[0].css
// console.log(purgecssResult)
})
it('keeps `99.9%`', () => {
expect(purgecssResult.includes('99.9%')).toBe(true)
})
})
})

describe('purge methods with raw content and default extractor', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ class Purgecss {
for (const { type, value } of selector.nodes) {
if (
SELECTOR_STANDARD_TYPES.includes(type) &&
typeof value !== 'undefined'
typeof value !== 'undefined' &&
/^\d/g.test(value) === false
) {
selectorsInRule.push(value)
} else if (
Expand Down

0 comments on commit be5ac0f

Please sign in to comment.