Skip to content

Commit

Permalink
fix: animation value replacement (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justineo authored and yyx990803 committed Dec 15, 2017
1 parent ddcea20 commit 6d3c5b2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/style-compiler/plugins/scope-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ module.exports = postcss.plugin('add-id', ({ id }) => root => {
decl.value = decl.value.split(',')
.map(v => {
const vals = v.trim().split(/\s+/)
const name = vals[0]
if (keyframes[name]) {
return [keyframes[name]].concat(vals.slice(1)).join(' ')
const i = vals.findIndex(val => keyframes[val])
if (i !== -1) {
vals.splice(i, 1, keyframes[vals[i]])
return vals.join(' ')
} else {
return v
}
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/scoped-css.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ h1 {
animation-name: color;
animation-duration: 5s;
}
.anim-3 {
animation: 5s color infinite, 5s other;
}
.anim-multiple {
animation: color 5s infinite, opacity 2s;
}
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ describe('vue-loader', () => {
// scoped keyframes
expect(style).to.contain(`.anim[${id}] {\n animation: color-${id} 5s infinite, other 5s;`)
expect(style).to.contain(`.anim-2[${id}] {\n animation-name: color-${id}`)
expect(style).to.contain(`.anim-3[${id}] {\n animation: 5s color-${id} infinite, 5s other;`)
expect(style).to.contain(`@keyframes color-${id} {`)
expect(style).to.contain(`@-webkit-keyframes color-${id} {`)

Expand Down

0 comments on commit 6d3c5b2

Please sign in to comment.