wip(compiler-ssr): v-bind with static keys
This commit is contained in:
@@ -33,13 +33,18 @@ export function renderAttrs(
|
||||
} else if (key === 'style') {
|
||||
ret += ` style="${renderStyle(value)}"`
|
||||
} else {
|
||||
ret += renderAttr(key, value, tag)
|
||||
ret += renderDynamicAttr(key, value, tag)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
export function renderAttr(key: string, value: unknown, tag?: string): string {
|
||||
// render an attr with dynamic (unknown) key.
|
||||
export function renderDynamicAttr(
|
||||
key: string,
|
||||
value: unknown,
|
||||
tag?: string
|
||||
): string {
|
||||
if (value == null) {
|
||||
return ``
|
||||
}
|
||||
@@ -56,6 +61,15 @@ export function renderAttr(key: string, value: unknown, tag?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
// 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 renderAttr(key: string, value: unknown): string {
|
||||
if (value == null) {
|
||||
return ``
|
||||
}
|
||||
return ` ${key}="${escapeHtml(value)}"`
|
||||
}
|
||||
|
||||
export function renderClass(raw: unknown): string {
|
||||
return escapeHtml(normalizeClass(raw))
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ export {
|
||||
renderClass as _renderClass,
|
||||
renderStyle as _renderStyle,
|
||||
renderAttrs as _renderAttrs,
|
||||
renderAttr as _renderAttr
|
||||
renderAttr as _renderAttr,
|
||||
renderDynamicAttr as _renderDynamicAttr
|
||||
} from './helpers/renderAttrs'
|
||||
export { interpolate as _interpolate } from './helpers/interpolate'
|
||||
export { renderList as _renderList } from './helpers/renderList'
|
||||
|
||||
Reference in New Issue
Block a user