Skip to content

Commit bff7e1d

Browse files
committed
fix false possitive key warning
1 parent 496bcd1 commit bff7e1d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/idom/core/vdom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def vdom(
174174
if event_handlers:
175175
model["eventHandlers"] = event_handlers
176176

177-
if key:
177+
if key != "":
178178
model["key"] = key
179179

180180
if import_source is not None:
@@ -337,6 +337,6 @@ def _is_single_child(value: Any) -> bool:
337337
if (isinstance(child, ComponentType) and child.key is None) or (
338338
isinstance(child, Mapping) and "key" not in child
339339
):
340-
logger.error(f"Key not specified for dynamic child {child}")
340+
logger.error(f"Key not specified for child in list {child}")
341341

342342
return False

tests/test_core/test_vdom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def test_debug_log_cannot_verify_keypath_for_genereators(caplog):
336336
def test_debug_log_dynamic_children_must_have_keys(caplog):
337337
idom.vdom("div", [idom.vdom("div")])
338338
assert len(caplog.records) == 1
339-
assert caplog.records[0].message.startswith("Key not specified for dynamic child")
339+
assert caplog.records[0].message.startswith("Key not specified for child")
340340

341341
caplog.records.clear()
342342

@@ -346,4 +346,4 @@ def MyComponent():
346346

347347
idom.vdom("div", [MyComponent()])
348348
assert len(caplog.records) == 1
349-
assert caplog.records[0].message.startswith("Key not specified for dynamic child")
349+
assert caplog.records[0].message.startswith("Key not specified for child")

0 commit comments

Comments
 (0)