This commit is contained in:
Guo 2025-06-18 16:40:19 +03:00 committed by GitHub
commit 0872155f1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 3 deletions

View File

@ -39,6 +39,7 @@ import {
isBooleanAttr,
isBuiltInDirective,
isSSRSafeAttrName,
isString,
propsToAttrMap,
} from '@vue/shared'
import { SSRErrorCodes, createSSRCompilerError } from '../errors'
@ -423,9 +424,16 @@ function removeStaticBinding(
tag: TemplateLiteral['elements'],
binding: string,
) {
const regExp = new RegExp(`^ ${binding}=".+"$`)
const i = tag.findIndex(e => typeof e === 'string' && regExp.test(e))
const bindingStart = ` ${binding}="`
// tag must end with at least one character and "
const minLen = bindingStart.length + 2
const i = tag.findIndex(
e =>
isString(e) &&
e.length >= minLen &&
e.startsWith(bindingStart) &&
e[e.length - 1] === '"',
)
if (i > -1) {
tag.splice(i, 1)