diff --git a/__tests__/purgecss.test.js b/__tests__/purgecss.test.js index 1a47c170..657b1ff2 100644 --- a/__tests__/purgecss.test.js +++ b/__tests__/purgecss.test.js @@ -317,6 +317,10 @@ describe('special characters, with custom Extractor', () => { it('finds tailwind class', () => { expect(purgecssResult.includes('md\\:w-1\\/3')).toBe(true) }) + + it('discards unused class beginning with number', () => { + expect(purgecssResult.includes('\\32 -panel')).toBe(false) + }) }) describe('special characters, with custom Extractor as a function', () => { diff --git a/__tests__/test_examples/special_characters/special_characters.css b/__tests__/test_examples/special_characters/special_characters.css index 5e467db1..188124c2 100644 --- a/__tests__/test_examples/special_characters/special_characters.css +++ b/__tests__/test_examples/special_characters/special_characters.css @@ -9,3 +9,7 @@ .md\:w-1\/3 { color: green; } + +.\32 -panels { + color: red; +} diff --git a/src/index.js b/src/index.js index e2fc5a36..859fbd37 100644 --- a/src/index.js +++ b/src/index.js @@ -300,6 +300,10 @@ class Purgecss { return } + if (node.parent && node.parent.type === 'atrule' && node.parent.name === 'keyframes') { + return + } + let keepSelector = true node.selector = selectorParser(selectorsParsed => { selectorsParsed.walk(selector => { @@ -316,8 +320,7 @@ class Purgecss { for (const { type, value } of selector.nodes) { if ( SELECTOR_STANDARD_TYPES.includes(type) && - typeof value !== 'undefined' && - /^\d/g.test(value) === false + typeof value !== 'undefined' ) { selectorsInRule.push(value) } else if (