Skip to content

Commit 347ef1d

Browse files
authored
chore(compiler-sfc): optimize the regular expression for matching @keyframes (#13566)
1 parent f97c4d4 commit 347ef1d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/compiler-sfc/src/style/pluginScoped.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { warn } from '../warn'
1010

1111
const animationNameRE = /^(-\w+-)?animation-name$/
1212
const animationRE = /^(-\w+-)?animation$/
13+
const keyframesRE = /^(?:-\w+-)?keyframes$/
1314

1415
const scopedPlugin: PluginCreator<string> = (id = '') => {
1516
const keyframes = Object.create(null)
@@ -21,10 +22,7 @@ const scopedPlugin: PluginCreator<string> = (id = '') => {
2122
processRule(id, rule)
2223
},
2324
AtRule(node) {
24-
if (
25-
/-?keyframes$/.test(node.name) &&
26-
!node.params.endsWith(`-${shortId}`)
27-
) {
25+
if (keyframesRE.test(node.name) && !node.params.endsWith(`-${shortId}`)) {
2826
// register keyframes
2927
keyframes[node.params] = node.params = node.params + '-' + shortId
3028
}
@@ -72,7 +70,7 @@ function processRule(id: string, rule: Rule) {
7270
processedRules.has(rule) ||
7371
(rule.parent &&
7472
rule.parent.type === 'atrule' &&
75-
/-?keyframes$/.test((rule.parent as AtRule).name))
73+
keyframesRE.test((rule.parent as AtRule).name))
7674
) {
7775
return
7876
}

0 commit comments

Comments
 (0)