fix(runtime-core): do not use bail patchFlag on cloned vnodes

fix #1665

- cloned vnodes with extra props will receive only the full props flag
- this commit affects `cloneVNode` behavior when used in manual render
  functions.
  - ok for normal elements since elements only use patchFlags for own
    props optimization
  - full props flag is skipped for fragments because fragments use
    patchFlags only for children optimization
  - this also affects `shouldUpdateComponent` where it should now only
    respect patchFlags in optimized mode, since component vnodes use
    the patchFlag for both props and slots optimization checks.
This commit is contained in:
Evan You
2020-07-21 12:35:34 -04:00
parent 324167d3d2
commit 6390ddfb7d
2 changed files with 13 additions and 17 deletions

View File

@@ -279,7 +279,7 @@ export function shouldUpdateComponent(
return true
}
if (patchFlag > 0) {
if (optimized && patchFlag > 0) {
if (patchFlag & PatchFlags.DYNAMIC_SLOTS) {
// slot content that references values that might have changed,
// e.g. in a v-for
@@ -300,7 +300,7 @@ export function shouldUpdateComponent(
}
}
}
} else if (!optimized) {
} else {
// this path is only taken by manually written render functions
// so presence of any children leads to a forced update
if (prevChildren || nextChildren) {