From 2026dd78901d6a12e8e9830dbae07fcfa215d5a6 Mon Sep 17 00:00:00 2001 From: NoahKa0 Date: Wed, 18 Jan 2023 22:13:24 +0100 Subject: [PATCH] fix(patch): Do not consider nodes with different scope ids the same When patching a node the scope id might change. When it does the flow should be followed for updating non-same elements to make sure it is updated correctly in the DOM. fix #10416 --- src/core/vdom/patch.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index bff48f44bea..6d7c54aab3a 100644 --- a/src/core/vdom/patch.js +++ b/src/core/vdom/patch.js @@ -40,7 +40,8 @@ function sameVnode (a, b) { a.tag === b.tag && a.isComment === b.isComment && isDef(a.data) === isDef(b.data) && - sameInputType(a, b) + sameInputType(a, b) && + findScopeId(a) === findScopeId(b) ) || ( isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error) @@ -67,6 +68,20 @@ function createKeyToOldIdx (children, beginIdx, endIdx) { return map } +function findScopeId (node) { + if (isDef(node.fnScopeId)) { + return node.fnScopeId + } + + let ancestor = node + while (ancestor) { + if (isDef(ancestor.context) && isDef(ancestor.context.$options._scopeId)) { + return ancestor.context.$options._scopeId + } + ancestor = ancestor.parent + } +} + export function createPatchFunction (backend) { let i, j const cbs = {}