From 72077afcd0c51819f24587d3c728e2984b4a463c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=B1=E5=90=B9=E8=89=B2=E5=BE=A1=E5=AE=88?= <85992002+KazariEX@users.noreply.github.com> Date: Fri, 4 Jul 2025 15:14:55 +0800 Subject: [PATCH] fix(compiler-sfc): match `@keyframes` exactly --- packages/compiler-sfc/src/style/pluginScoped.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 }