isBooleanAttr,
isKnownHtmlAttr,
isKnownSvgAttr,
- isObject,
isOn,
+ isRenderableAttrValue,
isReservedProp,
isString,
normalizeClass,
} else {
actual = false
}
- expected =
- isObject(clientValue) || clientValue == null
- ? false
- : String(clientValue)
+ expected = isRenderableAttrValue(clientValue)
+ ? String(clientValue)
+ : false
}
if (actual !== expected) {
mismatchType = `attribute`
-import { escapeHtml, isSVGTag, stringifyStyle } from '@vue/shared'
+import {
+ escapeHtml,
+ isRenderableAttrValue,
+ isSVGTag,
+ stringifyStyle,
+} from '@vue/shared'
import {
includeBooleanAttr,
isBooleanAttr,
value: unknown,
tag?: string,
): string {
- if (!isRenderableValue(value)) {
+ if (!isRenderableAttrValue(value)) {
return ``
}
const attrKey =
// 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))
}
`xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,` +
`xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`,
)
+
+/**
+ * Shared between server-renderer and runtime-core hydration logic
+ */
+export function isRenderableAttrValue(value: unknown): boolean {
+ if (value == null) {
+ return false
+ }
+ const type = typeof value
+ return type === 'string' || type === 'number' || type === 'boolean'
+}