|
|
@@ -1,4 +1,9 @@
|
|
|
-import { escapeHtml, isSVGTag, stringifyStyle } from '@vue/shared'
|
|
|
+import {
|
|
|
+ escapeHtml,
|
|
|
+ isRenderableAttrValue,
|
|
|
+ isSVGTag,
|
|
|
+ stringifyStyle,
|
|
|
+} from '@vue/shared'
|
|
|
import {
|
|
|
includeBooleanAttr,
|
|
|
isBooleanAttr,
|
|
|
@@ -47,7 +52,7 @@ export function ssrRenderDynamicAttr(
|
|
|
value: unknown,
|
|
|
tag?: string,
|
|
|
): string {
|
|
|
- if (!isRenderableValue(value)) {
|
|
|
+ if (!isRenderableAttrValue(value)) {
|
|
|
return ``
|
|
|
}
|
|
|
const attrKey =
|
|
|
@@ -69,20 +74,12 @@ export function ssrRenderDynamicAttr(
|
|
|
// Render a v-bind attr with static key. The key is pre-processed at compile
|
|
|
// time and we only need to check and escape value.
|
|
|
export function ssrRenderAttr(key: string, value: unknown): string {
|
|
|
- if (!isRenderableValue(value)) {
|
|
|
+ if (!isRenderableAttrValue(value)) {
|
|
|
return ``
|
|
|
}
|
|
|
return ` ${key}="${escapeHtml(value)}"`
|
|
|
}
|
|
|
|
|
|
-function isRenderableValue(value: unknown): boolean {
|
|
|
- if (value == null) {
|
|
|
- return false
|
|
|
- }
|
|
|
- const type = typeof value
|
|
|
- return type === 'string' || type === 'number' || type === 'boolean'
|
|
|
-}
|
|
|
-
|
|
|
export function ssrRenderClass(raw: unknown): string {
|
|
|
return escapeHtml(normalizeClass(raw))
|
|
|
}
|