From: 山吹色御守 <85992002+KazariEX@users.noreply.github.com> Date: Wed, 9 Jul 2025 02:31:20 +0000 (-0700) Subject: chore(compiler-sfc): optimize the regular expression for matching `@keyframes` (... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fvuejs%2Fcore.git chore(compiler-sfc): optimize the regular expression for matching `@keyframes` (#13566) --- diff --git a/packages/compiler-sfc/src/style/pluginScoped.ts b/packages/compiler-sfc/src/style/pluginScoped.ts index d0aaddd767..071b3a36b1 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 }