Skip to content

Commit 52227e2

Browse files
committed
made it a bit more stable
1 parent b4ab1c7 commit 52227e2

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

index.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -197,27 +197,27 @@ function localizeAnimationShorthandDeclValueNodes(nodes, context) {
197197
animation name of infinite from the second.
198198
*/
199199
var animationKeywords = {
200-
'alternate': 1,
201-
'alternate-reverse': 1,
202-
'backwards': 1,
203-
'both': 1,
204-
'ease': 1,
205-
'ease-in': 1,
206-
'ease-in-out': 1,
207-
'ease-out': 1,
208-
'forwards': 1,
209-
'infinite': 1,
210-
'linear': 1,
211-
'none': Infinity, // No matter how many times you write none, it will never be an animation name
212-
'normal': 1,
213-
'paused': 1,
214-
'reverse': 1,
215-
'running': 1,
216-
'step-end': 1,
217-
'step-start': 1,
218-
'initial': Infinity,
219-
'inherit': Infinity,
220-
'unset': Infinity,
200+
'$alternate': 1,
201+
'$alternate-reverse': 1,
202+
'$backwards': 1,
203+
'$both': 1,
204+
'$ease': 1,
205+
'$ease-in': 1,
206+
'$ease-in-out': 1,
207+
'$ease-out': 1,
208+
'$forwards': 1,
209+
'$infinite': 1,
210+
'$linear': 1,
211+
'$none': Infinity, // No matter how many times you write none, it will never be an animation name
212+
'$normal': 1,
213+
'$paused': 1,
214+
'$reverse': 1,
215+
'$running': 1,
216+
'$step-end': 1,
217+
'$step-start': 1,
218+
'$initial': Infinity,
219+
'$inherit': Infinity,
220+
'$unset': Infinity,
221221
};
222222

223223
var didParseAnimationName = false;
@@ -230,12 +230,12 @@ function localizeAnimationShorthandDeclValueNodes(nodes, context) {
230230
var shouldParseAnimationName = false;
231231

232232
if (!didParseAnimationName && value && validIdent.test(value)) {
233-
if (value in animationKeywords) {
234-
parsedAnimationKeywords[value] = (value in parsedAnimationKeywords)
235-
? (parsedAnimationKeywords[value] + 1)
233+
if ('$' + value in animationKeywords) {
234+
parsedAnimationKeywords['$' + value] = ('$' + value in parsedAnimationKeywords)
235+
? (parsedAnimationKeywords['$' + value] + 1)
236236
: 0;
237237

238-
shouldParseAnimationName = (parsedAnimationKeywords[value] >= animationKeywords[value]);
238+
shouldParseAnimationName = (parsedAnimationKeywords['$' + value] >= animationKeywords['$' + value]);
239239
} else {
240240
shouldParseAnimationName = true;
241241
}

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ var tests = [
199199
input: '.foo { animation: inherit; }',
200200
expected: ':local(.foo) { animation: inherit; }'
201201
},
202+
{
203+
should: 'handle "constructor" as animation name',
204+
input: '.foo { animation: constructor constructor; }',
205+
expected: ':local(.foo) { animation: :local(constructor) :local(constructor); }'
206+
},
202207
{
203208
should: 'default to global when mode provided',
204209
input: '.foo {}',

0 commit comments

Comments
 (0)