[JIT] Support animation lists (#5252)
* Support animation lists * Update tests
This commit is contained in:
parent
ca1a167a83
commit
b56b4c0b14
6 changed files with 248 additions and 80 deletions
|
|
@ -19,18 +19,23 @@ export default function () {
|
|||
matchUtilities(
|
||||
{
|
||||
animate: (value, { includeRules }) => {
|
||||
let { name: animationName } = parseAnimationValue(value)
|
||||
let animations = parseAnimationValue(value)
|
||||
|
||||
if (keyframes[animationName] !== undefined) {
|
||||
includeRules(keyframes[animationName], { respectImportant: false })
|
||||
}
|
||||
|
||||
if (animationName === undefined || keyframes[animationName] === undefined) {
|
||||
return { animation: value }
|
||||
for (let { name } of animations) {
|
||||
if (keyframes[name] !== undefined) {
|
||||
includeRules(keyframes[name], { respectImportant: false })
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
animation: value.replace(animationName, prefixName(animationName)),
|
||||
animation: animations
|
||||
.map(({ name, value }) => {
|
||||
if (name === undefined || keyframes[name] === undefined) {
|
||||
return value
|
||||
}
|
||||
return value.replace(name, prefixName(name))
|
||||
})
|
||||
.join(', '),
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ const DIGIT = /^(\d+)$/
|
|||
|
||||
export default function parseAnimationValue(input) {
|
||||
let animations = input.split(COMMA)
|
||||
let result = animations.map((animation) => {
|
||||
let result = {}
|
||||
let parts = animation.trim().split(SPACE)
|
||||
return animations.map((animation) => {
|
||||
let value = animation.trim()
|
||||
let result = { value }
|
||||
let parts = value.split(SPACE)
|
||||
let seen = new Set()
|
||||
|
||||
for (let part of parts) {
|
||||
|
|
@ -58,6 +59,4 @@ export default function parseAnimationValue(input) {
|
|||
|
||||
return result
|
||||
})
|
||||
|
||||
return animations.length > 1 ? result : result[0]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue