fix(版本对比): 版本对比算法处理加条件

--bug=1009791--user=郭雨琦 【性能测试】版本对比,一样的地方也标注了
This commit is contained in:
guoyuqi 2022-01-20 10:43:11 +08:00 committed by song-tianyang
parent a63f09aaa0
commit 643718657f
1 changed files with 13 additions and 2 deletions

View File

@ -210,7 +210,7 @@ function sameDetail(oldVnode,newVnode,sameNode){
if(isDef(oldVnode.children)&&isDef(newVnode.children)){
sameChildren(oldVnode.children,newVnode.children,sameNode)
}
//剩最后的子节点的时候,分类型做判断
//剩最后的子节点的时候,分类型做判断如果最后的子节点有一个不相同sameNode就置空
if(isUndef(oldVnode.child)&&isUndef(newVnode.child)&&isUndef(oldVnode.children)&&isUndef(newVnode.children)){
if(isDef(oldVnode.text)&&isDef(newVnode.text)){
if(oldVnode.text===newVnode.text){
@ -233,6 +233,12 @@ function sameDetail(oldVnode,newVnode,sameNode){
}else{
sameNode.nodeArray = [];
}
}else if(oldVnode.tag==='textarea'&&newVnode.tag==='textarea'){
if(oldVnode.elm.value===newVnode.elm.value){
sameNode.nodeArray.push(newVnode.elm);
}else {
sameNode.nodeArray = [];
}
}
}
else {
@ -288,7 +294,7 @@ function diffDetail(oldVnode,newVnode,diffNode){
diffNode.nodeArray.push(newVnode.elm);
}
}else if(isDef(oldVnode.tag)&&isDef(newVnode.tag)){
if((oldVnode.tag==='input'&&newVnode.tag==='input')||(oldVnode.tag==='textarea'&&newVnode.tag==='textarea')){
if(oldVnode.tag==='input'&&newVnode.tag==='input'){
if(oldVnode.elm.value!==newVnode.elm.value){
diffNode.oldNodeArray.push(oldVnode.elm);
diffNode.nodeArray.push(newVnode.elm);
@ -300,6 +306,11 @@ function diffDetail(oldVnode,newVnode,diffNode){
}
}
}
}else if(oldVnode.tag==='textarea'&&newVnode.tag==='textarea'){
if(oldVnode.elm.value!==newVnode.elm.value){
diffNode.oldNodeArray.push(oldVnode.elm);
diffNode.nodeArray.push(newVnode.elm);
}
}
}
else {