Skip to content

Commit 6cb9475

Browse files
authored
fix(compiler-sfc): scope Id should not be attached to @Keyframe breakpoint rules (#3308)
fix #3304
1 parent 9717756 commit 6cb9475

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/compiler-sfc/__tests__/compileStyle.spec.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ describe('SFC scoped CSS', () => {
215215
expect(style).toContain(
216216
`.anim-multiple-2[data-v-test] {\n animation-name: color-test,opacity-test;`
217217
)
218-
expect(style).toContain(`@keyframes opacity-test {`)
219-
expect(style).toContain(`@-webkit-keyframes opacity-test {`)
218+
expect(style).toContain(`@keyframes opacity-test {\nfrom { opacity: 0;`)
219+
expect(style).toContain(
220+
`@-webkit-keyframes opacity-test {\nfrom { opacity: 0;`
221+
)
220222
})
221223

222224
// vue-loader/#1370

packages/compiler-sfc/src/stylePluginScoped.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PluginCreator, Rule } from 'postcss'
1+
import { PluginCreator, Rule, AtRule } from 'postcss'
22
import selectorParser from 'postcss-selector-parser'
33
import { warn } from './warn'
44

@@ -62,7 +62,12 @@ const scopedPlugin: PluginCreator<string> = (id = '') => {
6262
const processedRules = new WeakSet<Rule>()
6363

6464
function processRule(id: string, rule: Rule) {
65-
if (processedRules.has(rule)) {
65+
if (
66+
processedRules.has(rule) ||
67+
(rule.parent &&
68+
rule.parent.type === 'atrule' &&
69+
/-?keyframes$/.test((rule.parent as AtRule).name))
70+
) {
6671
return
6772
}
6873
processedRules.add(rule)

0 commit comments

Comments
 (0)