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