( n1: VNode, n2: VNode, shallow = false, )
| 2521 | * position, el should be inherited from previous nodes. |
| 2522 | */ |
| 2523 | export function traverseStaticChildren( |
| 2524 | n1: VNode, |
| 2525 | n2: VNode, |
| 2526 | shallow = false, |
| 2527 | ): void { |
| 2528 | const ch1 = n1.children |
| 2529 | const ch2 = n2.children |
| 2530 | if (isArray(ch1) && isArray(ch2)) { |
| 2531 | for (let i = 0; i < ch1.length; i++) { |
| 2532 | // this is only called in the optimized path so array children are |
| 2533 | // guaranteed to be vnodes |
| 2534 | const c1 = ch1[i] as VNode |
| 2535 | let c2 = ch2[i] as VNode |
| 2536 | if (c2.shapeFlag & ShapeFlags.ELEMENT && !c2.dynamicChildren) { |
| 2537 | if (c2.patchFlag <= 0 || c2.patchFlag === PatchFlags.NEED_HYDRATION) { |
| 2538 | c2 = ch2[i] = cloneIfMounted(ch2[i] as VNode) |
| 2539 | c2.el = c1.el |
| 2540 | } |
| 2541 | if (!shallow && c2.patchFlag !== PatchFlags.BAIL) |
| 2542 | traverseStaticChildren(c1, c2) |
| 2543 | } |
| 2544 | // #6852 also inherit for text nodes |
| 2545 | if (c2.type === Text) { |
| 2546 | // avoid cached text nodes retaining detached dom nodes |
| 2547 | if (c2.patchFlag === PatchFlags.CACHED) { |
| 2548 | c2 = ch2[i] = cloneIfMounted(c2) |
| 2549 | } |
| 2550 | c2.el = c1.el |
| 2551 | } |
| 2552 | // #2324 also inherit for comment nodes, but not placeholders (e.g. v-if which |
| 2553 | // would have received .el during block patch) |
| 2554 | if (c2.type === Comment && !c2.el) { |
| 2555 | c2.el = c1.el |
| 2556 | } |
| 2557 | |
| 2558 | if (__DEV__) { |
| 2559 | c2.el && (c2.el.__vnode = c2) |
| 2560 | } |
| 2561 | } |
| 2562 | } |
| 2563 | } |
| 2564 | |
| 2565 | // https://en.wikipedia.org/wiki/Longest_increasing_subsequence |
| 2566 | function getSequence(arr: number[]): number[] { |
no test coverage detected