chore(compiler-sfc): optimize the regular expression for matching `@keyframes` (#13566)
ci / test (push) Has been cancelled Details
ci / continuous-release (push) Has been cancelled Details
size data / upload (push) Has been cancelled Details
Lock Closed Issues / action (push) Has been cancelled Details
Auto close issues with "can't reproduce" label / close-issues (push) Has been cancelled Details

This commit is contained in:
山吹色御守 2025-07-08 19:31:20 -07:00 committed by GitHub
parent f97c4d4e6e
commit 347ef1d3f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 5 deletions

View File

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