]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(compiler-sfc): optimize the regular expression for matching `@keyframes` (... main
author山吹色御守 <85992002+KazariEX@users.noreply.github.com>
Wed, 9 Jul 2025 02:31:20 +0000 (19:31 -0700)
committerGitHub <noreply@github.com>
Wed, 9 Jul 2025 02:31:20 +0000 (10:31 +0800)
packages/compiler-sfc/src/style/pluginScoped.ts

index d0aaddd7676ba41d59eb1ed8899718dcbb89f746..071b3a36b12a6ee23a1da7669ce73dce8a488e17 100644 (file)
@@ -10,6 +10,7 @@ import { warn } from '../warn'
 
 const animationNameRE = /^(-\w+-)?animation-name$/
 const animationRE = /^(-\w+-)?animation$/
+const keyframesRE = /^(?:-\w+-)?keyframes$/
 
 const scopedPlugin: PluginCreator<string> = (id = '') => {
   const keyframes = Object.create(null)
@@ -21,10 +22,7 @@ const scopedPlugin: PluginCreator<string> = (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
   }