diff --git a/packages/compiler-sfc/src/style/pluginScoped.ts b/packages/compiler-sfc/src/style/pluginScoped.ts index d0aaddd7676..071b3a36b12 100644 --- a/packages/compiler-sfc/src/style/pluginScoped.ts +++ b/packages/compiler-sfc/src/style/pluginScoped.ts @@ -10,6 +10,7 @@ import { warn } from '../warn' const animationNameRE = /^(-\w+-)?animation-name$/ const animationRE = /^(-\w+-)?animation$/ +const keyframesRE = /^(?:-\w+-)?keyframes$/ const scopedPlugin: PluginCreator = (id = '') => { const keyframes = Object.create(null) @@ -21,10 +22,7 @@ const scopedPlugin: PluginCreator = (id = '') => { processRule(id, rule) }, AtRule(node) { - if ( - /-?keyframes$/.test(node.name) && - !node.params.endsWith(`-${shortId}`) - ) { + if (keyframesRE.test(node.name) && !node.params.endsWith(`-${shortId}`)) { // register keyframes keyframes[node.params] = node.params = node.params + '-' + shortId } @@ -72,7 +70,7 @@ function processRule(id: string, rule: Rule) { processedRules.has(rule) || (rule.parent && rule.parent.type === 'atrule' && - /-?keyframes$/.test((rule.parent as AtRule).name)) + keyframesRE.test((rule.parent as AtRule).name)) ) { return }