From a2e78834127fc80da1dbd45cf91b23c8c3ab51d9 Mon Sep 17 00:00:00 2001 From: Shashank Yadav <65058495+shashank11yadav@users.noreply.github.com> Date: Sun, 29 Nov 2026 23:44:59 -0700 Subject: [PATCH] Return self from DualMap.add_child DualMap.add_child returned None, so calls could not be chained, unlike add_child on other elements. Return self at the end, as Marker.add_child does. --- folium/plugins/dual_map.py | 1 + tests/plugins/test_dual_map.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/folium/plugins/dual_map.py b/folium/plugins/dual_map.py index c410aaf994..c81eba31dd 100644 --- a/folium/plugins/dual_map.py +++ b/folium/plugins/dual_map.py @@ -105,6 +105,7 @@ def add_child(self, child, name=None, index=None): if index is None: index = len(self.m2._children) self.children_for_m2.append((child, name, index)) + return self def on(self, **event_map: JsCode): """Add event handlers to both maps at once""" diff --git a/tests/plugins/test_dual_map.py b/tests/plugins/test_dual_map.py index 30cee8ae10..edac74fce2 100644 --- a/tests/plugins/test_dual_map.py +++ b/tests/plugins/test_dual_map.py @@ -29,3 +29,11 @@ def test_dual_map(): """) assert normalize(tmpl.render(this=m)) in out + + +def test_dual_map_add_child_returns_self(): + m = folium.plugins.DualMap((0, 0)) + assert m.add_child(folium.Marker((0, 0))) is m + # Chaining add_child calls adds every child to both maps. + m.add_child(folium.Marker((1, 1))).add_child(folium.Marker((2, 2))) + assert len(m.children_for_m2) == 3