mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
Another link resolution fix
commit_hash:71aa042987af2b242632f1f161811b7a9bb54b33
This commit is contained in:
@@ -26723,7 +26723,9 @@
|
||||
"test_data/parsing_test_data/templates/deeply_nested_card.json":"divkit/public/test_data/parsing_test_data/templates/deeply_nested_card.json",
|
||||
"test_data/parsing_test_data/templates/direct_value_overrides_link.json":"divkit/public/test_data/parsing_test_data/templates/direct_value_overrides_link.json",
|
||||
"test_data/parsing_test_data/templates/invalid_value_replaced_with_default_value_in_div_text.json":"divkit/public/test_data/parsing_test_data/templates/invalid_value_replaced_with_default_value_in_div_text.json",
|
||||
"test_data/parsing_test_data/templates/link_in_intermediate_template.json":"divkit/public/test_data/parsing_test_data/templates/link_in_intermediate_template.json",
|
||||
"test_data/parsing_test_data/templates/link_in_leaf_template.json":"divkit/public/test_data/parsing_test_data/templates/link_in_leaf_template.json",
|
||||
"test_data/parsing_test_data/templates/link_in_nested_property.json":"divkit/public/test_data/parsing_test_data/templates/link_in_nested_property.json",
|
||||
"test_data/parsing_test_data/templates/link_is_overridden_in_derived_template.json":"divkit/public/test_data/parsing_test_data/templates/link_is_overridden_in_derived_template.json",
|
||||
"test_data/parsing_test_data/templates/nested_template_usage.json":"divkit/public/test_data/parsing_test_data/templates/nested_template_usage.json",
|
||||
"test_data/parsing_test_data/templates/same_link_used_in_two_places.json":"divkit/public/test_data/parsing_test_data/templates/same_link_used_in_two_places.json",
|
||||
|
||||
@@ -100,7 +100,8 @@ final class UntypedDivTemplateResolver {
|
||||
if let dict = value as? [String: Any] {
|
||||
if let type = dict["type"] as? String,
|
||||
let resolvedTemplate = resolveTemplate(named: type).value {
|
||||
let parameterNames = collectParameterNames(from: resolvedTemplate)
|
||||
var parameterNames = collectParameterNames(from: resolvedTemplate)
|
||||
parameterNames.formUnion(collectParameterNames(from: dict))
|
||||
return resolveInstanceLinks(
|
||||
in: dict,
|
||||
linkSource: linkSource,
|
||||
@@ -186,7 +187,9 @@ final class UntypedDivTemplateResolver {
|
||||
!visited.contains(type),
|
||||
let resolvedTemplate = resolveTemplate(named: type).value {
|
||||
visited.insert(type)
|
||||
return collectParameterNames(from: resolvedTemplate, visited: &visited)
|
||||
var names = collectParameterNames(from: dict, visited: &visited)
|
||||
names.formUnion(collectParameterNames(from: resolvedTemplate, visited: &visited))
|
||||
return names
|
||||
}
|
||||
return collectParameterNames(from: dict, visited: &visited)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"description": "Link (titleTextRef) exist in the middle of template resolution chain (nested_container)",
|
||||
"templates": {
|
||||
"root_container": {
|
||||
"type": "container",
|
||||
"items": [
|
||||
{
|
||||
"type": "nested_container"
|
||||
}
|
||||
]
|
||||
},
|
||||
"nested_container": {
|
||||
"type": "container",
|
||||
"items": [
|
||||
{
|
||||
"type": "title_text",
|
||||
"$text": "titleTextRef"
|
||||
}
|
||||
]
|
||||
},
|
||||
"title_text": {
|
||||
"type": "text"
|
||||
}
|
||||
},
|
||||
"card": {
|
||||
"log_id": "test",
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"titleTextRef": "Title Text",
|
||||
"type": "root_container"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expected": {
|
||||
"card": {
|
||||
"log_id": "test",
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"items": [
|
||||
{
|
||||
"type": "container",
|
||||
"items": [
|
||||
{
|
||||
"text": "Title Text",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"description": "Link (image_start) not for direct property of text, but for nested properties (images)",
|
||||
"card": {
|
||||
"log_id": "test",
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"image_start": 5,
|
||||
"type": "root_container"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"templates": {
|
||||
"title_text": {
|
||||
"type": "text"
|
||||
},
|
||||
"root_container": {
|
||||
"type": "container",
|
||||
"items": [
|
||||
{
|
||||
"text": "Title",
|
||||
"images": [
|
||||
{
|
||||
"$start": "image_start",
|
||||
"url": "https://yastatic.net/s3/home/divkit/chess.png"
|
||||
}
|
||||
],
|
||||
"type": "title_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"expected": {
|
||||
"card": {
|
||||
"log_id": "test",
|
||||
"states": [
|
||||
{
|
||||
"state_id": 0,
|
||||
"div": {
|
||||
"type": "container",
|
||||
"items": [
|
||||
{
|
||||
"text": "Title",
|
||||
"images": [
|
||||
{
|
||||
"start": 5,
|
||||
"url": "https://yastatic.net/s3/home/divkit/chess.png"
|
||||
}
|
||||
],
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user