Skip to content

Commit 2f299fc

Browse files
committed
Revert "make keyframes scoped (close #731)"
This reverts commit 35229b0.
1 parent 063001e commit 2f299fc

File tree

3 files changed

+5
-30
lines changed

3 files changed

+5
-30
lines changed

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@ var selectorParser = require('postcss-selector-parser')
33

44
module.exports = postcss.plugin('add-id', function (opts) {
55
return function (root) {
6-
var keyframes = Object.create(null)
7-
86
root.each(function rewriteSelector (node) {
97
if (!node.selector) {
108
// handle media queries
11-
if (node.type === 'atrule') {
12-
if (node.name === 'media') {
13-
node.each(rewriteSelector)
14-
} else if (node.name === 'keyframes') {
15-
// register keyframes
16-
keyframes[node.params] = node.params = node.params + '-' + opts.id
17-
}
9+
if (node.type === 'atrule' && node.name === 'media') {
10+
node.each(rewriteSelector)
1811
}
1912
return
2013
}
@@ -30,13 +23,5 @@ module.exports = postcss.plugin('add-id', function (opts) {
3023
})
3124
}).process(node.selector).result
3225
})
33-
34-
if (Object.keys(keyframes).length) {
35-
root.walkDecls(decl => {
36-
if (/-?animation$/.test(decl.prop) && keyframes[decl.value]) {
37-
decl.value = keyframes[decl.value]
38-
}
39-
})
40-
}
4126
}
4227
})

test/fixtures/scoped-css.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
h1 {
99
color: green;
1010
}
11-
.anim {
12-
animation: color;
13-
}
14-
@keyframes color {
15-
from { color: red; }
16-
to { color: green; }
17-
}
1811
</style>
1912

2013
<template>

test/test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,9 @@ describe('vue-loader', function () {
193193

194194
var style = window.document.querySelector('style').textContent
195195
style = normalizeNewline(style)
196-
expect(style).to.contain(`.test[${id}] {\n color: yellow;\n}`)
197-
expect(style).to.contain(`.test[${id}]:after {\n content: \'bye!\';\n}`)
198-
expect(style).to.contain(`h1[${id}] {\n color: green;\n}`)
199-
// scoped keyframes
200-
expect(style).to.contain(`.anim[${id}] {\n animation: color-${id};\n}`)
201-
expect(style).to.contain(`@keyframes color-${id} {`)
196+
expect(style).to.contain('.test[' + id + '] {\n color: yellow;\n}')
197+
expect(style).to.contain('.test[' + id + ']:after {\n content: \'bye!\';\n}')
198+
expect(style).to.contain('h1[' + id + '] {\n color: green;\n}')
202199
done()
203200
})
204201
})

0 commit comments

Comments
 (0)