Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix animation value replacement for scoped CSS #1058

Merged
merged 1 commit into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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