fix(runtime-dom): consistently remove boolean attributes for falsy values (#4348)

This commit is contained in:
skirtle
2021-08-16 23:18:36 +01:00
committed by GitHub
parent f855ccb2c1
commit 620a69b871
12 changed files with 70 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ import {
isOn,
isSSRSafeAttrName,
isBooleanAttr,
includeBooleanAttr,
makeMap
} from '@vue/shared'
@@ -52,7 +53,7 @@ export function ssrRenderDynamicAttr(
? key // preserve raw name on custom elements
: propsToAttrMap[key] || key.toLowerCase()
if (isBooleanAttr(attrKey)) {
return value === false ? `` : ` ${attrKey}`
return includeBooleanAttr(value) ? ` ${attrKey}` : ``
} else if (isSSRSafeAttrName(attrKey)) {
return value === '' ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`
} else {

View File

@@ -27,6 +27,7 @@ export {
export { ssrInterpolate } from './helpers/ssrInterpolate'
export { ssrRenderList } from './helpers/ssrRenderList'
export { ssrRenderSuspense } from './helpers/ssrRenderSuspense'
export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared'
// v-model helpers
export {