Skip to content

Commit

Permalink
ensure we don't override the name (#5602)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RobinMalfait committed Sep 26, 2021
1 parent c03f9ad commit 4cb1de0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util/parseAnimationValue.js
Expand Up @@ -54,7 +54,13 @@ export default function parseAnimationValue(input) {
} else if (!seen.has('DELAY') && TIME.test(part)) {
result.delay = part
seen.add('DELAY')
} else result.name = part
} else if (!seen.has('NAME')) {
result.name = part
seen.add('NAME')
} else {
if (!result.unknown) result.unknown = []
result.unknown.push(part)
}
}

return result
Expand Down
13 changes: 13 additions & 0 deletions tests/parseAnimationValue.test.js
Expand Up @@ -38,6 +38,19 @@ describe('Tailwind Defaults', () => {
})
})

describe('css variables', () => {
it('should be possible to use css variables', () => {
let parsed = parseAnimationValue('jump var(--animation-duration, 10s) linear infinite')
expect(parsed[0]).toEqual({
value: 'jump var(--animation-duration, 10s) linear infinite',
name: 'jump',
timingFunction: 'linear',
iterationCount: 'infinite',
unknown: ['var(--animation-duration, 10s)'],
})
})
})

describe('MDN Examples', () => {
it.each([
[
Expand Down

0 comments on commit 4cb1de0

Please sign in to comment.