feat(hmr): reload and force slot update on re-render

This commit is contained in:
Evan You
2019-12-12 18:13:59 -05:00
parent ef50c333ce
commit f77ae132e5
7 changed files with 73 additions and 16 deletions

View File

@@ -111,10 +111,25 @@ export function renderComponentRoot(
export function shouldUpdateComponent(
prevVNode: VNode,
nextVNode: VNode,
parentComponent: ComponentInternalInstance | null,
optimized?: boolean
): boolean {
const { props: prevProps, children: prevChildren } = prevVNode
const { props: nextProps, children: nextChildren, patchFlag } = nextVNode
// Parent component's render function was hot-updated. Since this may have
// caused the child component's slots content to have changed, we need to
// force the child to update as well.
if (
__BUNDLER__ &&
__DEV__ &&
(prevChildren || nextChildren) &&
parentComponent &&
parentComponent.renderUpdated
) {
return true
}
if (patchFlag > 0) {
if (patchFlag & PatchFlags.DYNAMIC_SLOTS) {
// slot content that references values that might have changed,