Skip to content

Commit 47c3317

Browse files
danielchabryyx990803
authored andcommitted
fix: scoping of multiple animations (#1030)
fix #1031
1 parent e5bc6ed commit 47c3317

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = postcss.plugin('add-id', ({ id }) => root => {
6363
if (/-?animation$/.test(decl.prop)) {
6464
decl.value = decl.value.split(',')
6565
.map(v => {
66-
const vals = v.split(/\s+/)
66+
const vals = v.trim().split(/\s+/)
6767
const name = vals[0]
6868
if (keyframes[name]) {
6969
return [keyframes[name]].concat(vals.slice(1)).join(' ')

test/fixtures/scoped-css.vue

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ h1 {
1515
animation-name: color;
1616
animation-duration: 5s;
1717
}
18+
.anim-multiple {
19+
animation: color 5s infinite, opacity 2s;
20+
}
21+
.anim-multiple-2 {
22+
animation-name: color, opacity;
23+
animation-duration: 5s, 2s;
24+
}
25+
1826
@keyframes color {
1927
from { color: red; }
2028
to { color: green; }
@@ -23,6 +31,14 @@ h1 {
2331
from { color: red; }
2432
to { color: green; }
2533
}
34+
@keyframes opacity {
35+
from { opacity: 0; }
36+
to { opacity: 1; }
37+
}
38+
@-webkit-keyframes opacity {
39+
from { opacity: 0; }
40+
to { opacity: 1; }
41+
}
2642
.foo p >>> .bar {
2743
color: red;
2844
}

test/test.js

+5
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ describe('vue-loader', () => {
213213
expect(style).to.contain(`.anim-2[${id}] {\n animation-name: color-${id}`)
214214
expect(style).to.contain(`@keyframes color-${id} {`)
215215
expect(style).to.contain(`@-webkit-keyframes color-${id} {`)
216+
217+
expect(style).to.contain(`.anim-multiple[${id}] {\n animation: color-${id} 5s infinite,opacity-${id} 2s;`)
218+
expect(style).to.contain(`.anim-multiple-2[${id}] {\n animation-name: color-${id},opacity-${id};`)
219+
expect(style).to.contain(`@keyframes opacity-${id} {`)
220+
expect(style).to.contain(`@-webkit-keyframes opacity-${id} {`)
216221
// >>> combinator
217222
expect(style).to.contain(`.foo p[${id}] .bar {\n color: red;\n}`)
218223
done()

0 commit comments

Comments
 (0)