Skip to content

Commit

Permalink
fix(compiler-sfc): scope Id should not be attached to @Keyframe break…
Browse files Browse the repository at this point in the history
…point rules (#3308)

fix #3304
  • Loading branch information
HcySunYang authored Mar 19, 2021
1 parent 9717756 commit 6cb9475
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/compiler-sfc/__tests__/compileStyle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ describe('SFC scoped CSS', () => {
expect(style).toContain(
`.anim-multiple-2[data-v-test] {\n animation-name: color-test,opacity-test;`
)
expect(style).toContain(`@keyframes opacity-test {`)
expect(style).toContain(`@-webkit-keyframes opacity-test {`)
expect(style).toContain(`@keyframes opacity-test {\nfrom { opacity: 0;`)
expect(style).toContain(
`@-webkit-keyframes opacity-test {\nfrom { opacity: 0;`
)
})

// vue-loader/#1370
Expand Down
9 changes: 7 additions & 2 deletions packages/compiler-sfc/src/stylePluginScoped.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PluginCreator, Rule } from 'postcss'
import { PluginCreator, Rule, AtRule } from 'postcss'
import selectorParser from 'postcss-selector-parser'
import { warn } from './warn'

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

function processRule(id: string, rule: Rule) {
if (processedRules.has(rule)) {
if (
processedRules.has(rule) ||
(rule.parent &&
rule.parent.type === 'atrule' &&
/-?keyframes$/.test((rule.parent as AtRule).name))
) {
return
}
processedRules.add(rule)
Expand Down

0 comments on commit 6cb9475

Please sign in to comment.