Skip to content

Commit

Permalink
fix: support animation percents
Browse files Browse the repository at this point in the history
  • Loading branch information
dhlolo committed Dec 9, 2021
1 parent e64151e commit 3a57097
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ coverage
node_modules
dist
.idea
.vscode
5 changes: 5 additions & 0 deletions src/__tests__/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ test('tag with attribute', 'label[for="email"]', (t, tree) => {
t.deepEqual(tree.nodes[0].nodes[1].type, 'attribute');
t.deepEqual(tree.nodes[0].nodes[1].quoteMark, '"');
});

test('keyframes animation tag selector', '0.00%', (t, tree) => {
t.deepEqual(tree.nodes[0].nodes[0].value, '0.00%');
t.deepEqual(tree.nodes[0].nodes[0].type, 'tag');
});
8 changes: 7 additions & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,13 @@ export default class Parser {
}
nextToken = this.nextToken;
}
const hasClass = indexesOf(word, '.').filter(i => word[i - 1] !== '\\');
const hasClass = indexesOf(word, '.').filter(i => {
// Allow escaped dot within class name
const escapedDot = word[i - 1] === '\\';
// Allow decimal numbers percent in @keyframes
const isKeyframesPercent = /^\d+\.\d+%$/.test(word);
return !escapedDot && !isKeyframesPercent;
});
let hasId = indexesOf(word, '#').filter(i => word[i - 1] !== '\\');
// Eliminate Sass interpolations from the list of id indexes
const interpolations = indexesOf(word, '#{');
Expand Down

0 comments on commit 3a57097

Please sign in to comment.