mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Added type check in complex rebind
commit_hash:bc6c3cfa3f3c4ffaafec97a3f61d47871fd35a58
This commit is contained in:
@@ -85,7 +85,7 @@ internal class RebindTask(
|
||||
lastExistingParent = null,
|
||||
)
|
||||
|
||||
if (existingToken.divHash == newToken.divHash) {
|
||||
if (existingToken.isCombinable(newToken)) {
|
||||
doNodeInSameMode(existingToken, newToken)
|
||||
} else {
|
||||
doNodeInExistingMode(existingToken)
|
||||
@@ -116,7 +116,7 @@ internal class RebindTask(
|
||||
val aloneExistingChild = mutableListOf<ExistingToken>()
|
||||
|
||||
existingToken.getChildrenTokens(combinedToken).forEach { existingChild ->
|
||||
val newChildWithSameHash = aloneNewChild.find { it.divHash == existingChild.divHash }
|
||||
val newChildWithSameHash = aloneNewChild.find { it.isCombinable(existingChild) }
|
||||
|
||||
if (newChildWithSameHash != null) {
|
||||
doNodeInSameMode(existingChild, newChildWithSameHash)
|
||||
@@ -155,7 +155,7 @@ internal class RebindTask(
|
||||
}
|
||||
|
||||
private fun doNodeInNewMode(newToken: NewToken) {
|
||||
val existingWithSameHash = aloneExisting.find { it.divHash == newToken.divHash }
|
||||
val existingWithSameHash = aloneExisting.find { it.isCombinable(newToken) }
|
||||
|
||||
if (existingWithSameHash != null) {
|
||||
aloneExisting.remove(existingWithSameHash)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yandex.div.core.view2.reuse
|
||||
|
||||
import com.yandex.div.core.util.type
|
||||
import com.yandex.div.internal.core.DivItemBuilderResult
|
||||
|
||||
internal abstract class Token(
|
||||
@@ -8,4 +9,8 @@ internal abstract class Token(
|
||||
) {
|
||||
val divHash: Int = item.div.propertiesHash()
|
||||
val div = item.div
|
||||
|
||||
fun isCombinable(other: Token): Boolean {
|
||||
return divHash == other.divHash && div.type == other.div.type
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user