feat: template ref handling + ref unmount

This commit is contained in:
Evan You
2019-08-19 18:06:20 -04:00
parent 10a2cf47ea
commit 8f9afdff64
3 changed files with 91 additions and 26 deletions

View File

@@ -3,10 +3,11 @@ export function patchDOMProp(
key: string,
value: any,
prevChildren: any,
parentComponent: any,
unmountChildren: any
) {
if ((key === 'innerHTML' || key === 'textContent') && prevChildren != null) {
unmountChildren(prevChildren)
unmountChildren(prevChildren, parentComponent)
}
el[key] = value
}

View File

@@ -13,6 +13,7 @@ export function patchProp(
prevValue: any,
isSVG: boolean,
prevChildren?: VNode[],
parentComponent?: any,
unmountChildren?: any
) {
switch (key) {
@@ -27,7 +28,14 @@ export function patchProp(
if (isOn(key)) {
patchEvent(el, key.slice(2).toLowerCase(), prevValue, nextValue)
} else if (!isSVG && key in el) {
patchDOMProp(el, key, nextValue, prevChildren, unmountChildren)
patchDOMProp(
el,
key,
nextValue,
prevChildren,
parentComponent,
unmountChildren
)
} else {
patchAttr(el, key, nextValue, isSVG)
}