Skip to content

Commit 3a57097

Browse files
authored
fix: support animation percents
1 parent e64151e commit 3a57097

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ coverage
33
node_modules
44
dist
55
.idea
6+
.vscode

src/__tests__/tags.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ test('tag with attribute', 'label[for="email"]', (t, tree) => {
3636
t.deepEqual(tree.nodes[0].nodes[1].type, 'attribute');
3737
t.deepEqual(tree.nodes[0].nodes[1].quoteMark, '"');
3838
});
39+
40+
test('keyframes animation tag selector', '0.00%', (t, tree) => {
41+
t.deepEqual(tree.nodes[0].nodes[0].value, '0.00%');
42+
t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');
43+
});

src/parser.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,13 @@ export default class Parser {
836836
}
837837
nextToken = this.nextToken;
838838
}
839-
const hasClass = indexesOf(word, '.').filter(i => word[i - 1] !== '\\');
839+
const hasClass = indexesOf(word, '.').filter(i => {
840+
// Allow escaped dot within class name
841+
const escapedDot = word[i - 1] === '\\';
842+
// Allow decimal numbers percent in @keyframes
843+
const isKeyframesPercent = /^\d+\.\d+%$/.test(word);
844+
return !escapedDot && !isKeyframesPercent;
845+
});
840846
let hasId = indexesOf(word, '#').filter(i => word[i - 1] !== '\\');
841847
// Eliminate Sass interpolations from the list of id indexes
842848
const interpolations = indexesOf(word, '#{');

0 commit comments

Comments
 (0)