wip(ssr): vdom serialization

This commit is contained in:
Evan You
2020-01-28 18:48:27 -05:00
parent 8857b4f288
commit 6f43c4b516
11 changed files with 286 additions and 48 deletions

View File

@@ -1,7 +1,18 @@
export function patchAttr(el: Element, key: string, value: any) {
if (value == null) {
// TODO explain why we are no longer checking boolean/enumerated here
export function patchAttr(
el: Element,
key: string,
value: any,
isSVG: boolean
) {
if (isSVG && key.indexOf('xlink:') === 0) {
// TODO handle xlink
} else if (value == null) {
el.removeAttribute(key)
} else {
// TODO in dev mode, warn against incorrect values for boolean or
// enumerated attributes
el.setAttribute(key, value)
}
}

View File

@@ -62,7 +62,7 @@ export function patchProp(
} else if (key === 'false-value') {
;(el as any)._falseValue = nextValue
}
patchAttr(el, key, nextValue)
patchAttr(el, key, nextValue, isSVG)
}
break
}