Skip to content

Commit 4cb1de0

Browse files
authored
ensure we don't override the name (#5602)
Keep track of unknown values (like css variables) in an unknown section. Currently we only need to know the name, so this will be good enough for now.
1 parent c03f9ad commit 4cb1de0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/util/parseAnimationValue.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ export default function parseAnimationValue(input) {
5454
} else if (!seen.has('DELAY') && TIME.test(part)) {
5555
result.delay = part
5656
seen.add('DELAY')
57-
} else result.name = part
57+
} else if (!seen.has('NAME')) {
58+
result.name = part
59+
seen.add('NAME')
60+
} else {
61+
if (!result.unknown) result.unknown = []
62+
result.unknown.push(part)
63+
}
5864
}
5965

6066
return result

tests/parseAnimationValue.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ describe('Tailwind Defaults', () => {
3838
})
3939
})
4040

41+
describe('css variables', () => {
42+
it('should be possible to use css variables', () => {
43+
let parsed = parseAnimationValue('jump var(--animation-duration, 10s) linear infinite')
44+
expect(parsed[0]).toEqual({
45+
value: 'jump var(--animation-duration, 10s) linear infinite',
46+
name: 'jump',
47+
timingFunction: 'linear',
48+
iterationCount: 'infinite',
49+
unknown: ['var(--animation-duration, 10s)'],
50+
})
51+
})
52+
})
53+
4154
describe('MDN Examples', () => {
4255
it.each([
4356
[

0 commit comments

Comments
 (0)