From 4b7f6ca4721e447ac1a4811502cf1ca3c76e69af Mon Sep 17 00:00:00 2001 From: Adrian Bannister Date: Mon, 23 Aug 2021 13:39:49 +1000 Subject: [PATCH] Keep keyframe decimals for prefixed @keyframes --- packages/purgecss/__tests__/keyframes.test.ts | 31 +++++++++++++++++++ packages/purgecss/src/index.ts | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/purgecss/__tests__/keyframes.test.ts b/packages/purgecss/__tests__/keyframes.test.ts index 4cda3c3b..7fcab164 100644 --- a/packages/purgecss/__tests__/keyframes.test.ts +++ b/packages/purgecss/__tests__/keyframes.test.ts @@ -90,3 +90,34 @@ describe("keep keyframe decimals", () => { expect(purgedCSS.includes("99.9%")).toBe(true); }); }); + +describe("keep webkit keyframe decimals", () => { + let purgedCSS: string; + beforeAll(async () => { + const resultsPurge = await new PurgeCSS().purge({ + content: [ + { + raw: '
', + extension: "html", + }, + ], + css: [ + { + raw: ` + @-webkit-keyframes xxx { + 0% {opacity: 0;} + 99.9% {opacity: 1;} + } + .xx { animation: xxx 200ms linear both } + `, + }, + ], + keyframes: false, + }); + purgedCSS = resultsPurge[0].css; + }); + + it("keeps `99.9%`", () => { + expect(purgedCSS.includes("99.9%")).toBe(true); + }); +}); diff --git a/packages/purgecss/src/index.ts b/packages/purgecss/src/index.ts index d4ac8cbb..64a8bffa 100644 --- a/packages/purgecss/src/index.ts +++ b/packages/purgecss/src/index.ts @@ -439,7 +439,7 @@ class PurgeCSS { if ( node.parent && isPostCSSAtRule(node.parent) && - node.parent.name === "keyframes" + node.parent.name.endsWith("keyframes") ) { return; }