Skip to content

Commit 6d3c5b2

Browse files
Justineoyyx990803
authored andcommitted
fix: animation value replacement (#1058)
1 parent ddcea20 commit 6d3c5b2

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/style-compiler/plugins/scope-id.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ module.exports = postcss.plugin('add-id', ({ id }) => root => {
6464
decl.value = decl.value.split(',')
6565
.map(v => {
6666
const vals = v.trim().split(/\s+/)
67-
const name = vals[0]
68-
if (keyframes[name]) {
69-
return [keyframes[name]].concat(vals.slice(1)).join(' ')
67+
const i = vals.findIndex(val => keyframes[val])
68+
if (i !== -1) {
69+
vals.splice(i, 1, keyframes[vals[i]])
70+
return vals.join(' ')
7071
} else {
7172
return v
7273
}

test/fixtures/scoped-css.vue

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ h1 {
1515
animation-name: color;
1616
animation-duration: 5s;
1717
}
18+
.anim-3 {
19+
animation: 5s color infinite, 5s other;
20+
}
1821
.anim-multiple {
1922
animation: color 5s infinite, opacity 2s;
2023
}

test/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ describe('vue-loader', () => {
211211
// scoped keyframes
212212
expect(style).to.contain(`.anim[${id}] {\n animation: color-${id} 5s infinite, other 5s;`)
213213
expect(style).to.contain(`.anim-2[${id}] {\n animation-name: color-${id}`)
214+
expect(style).to.contain(`.anim-3[${id}] {\n animation: 5s color-${id} infinite, 5s other;`)
214215
expect(style).to.contain(`@keyframes color-${id} {`)
215216
expect(style).to.contain(`@-webkit-keyframes color-${id} {`)
216217

0 commit comments

Comments
 (0)