From 3b20a059ca5d44160065eb128109b68e38ec226d Mon Sep 17 00:00:00 2001 From: hksamm Date: Sun, 23 Aug 2026 22:11:38 +0900 Subject: [PATCH] Forward unrecognised Leaflet options in path_options path_options pops the options it knows about and builds the result from those, but never forwards the remaining kwargs. Leaflet Path options that it does not name explicitly -- interactive, pane, renderer, attribution and so on -- were therefore silently dropped from every vector overlay (Circle, CircleMarker, PolyLine, Polygon, Rectangle). This is inconsistent with the rest of folium: FeatureGroup, TileLayer, GeoJson and the others all forward **kwargs to Leaflet via remove_empty. The special-cased pass-through of tags, className and gradient shows the intent was to support Leaflet options, just incompletely. Forward the leftover options too, so e.g. CircleMarker(..., interactive= False) actually reaches Leaflet. Co-Authored-By: Claude Opus 5 --- folium/vector_layers.py | 5 +++++ tests/test_vector_layers.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/folium/vector_layers.py b/folium/vector_layers.py index 5b618dfd6a..7a822c57fb 100644 --- a/folium/vector_layers.py +++ b/folium/vector_layers.py @@ -123,6 +123,11 @@ def path_options( "bubblingMouseEvents": kwargs.pop("bubblingMouseEvents", True), } default.update(extra_options) + # Pass any remaining options straight through to Leaflet, matching how + # the other folium option builders forward **kwargs. Without this, Path + # options such as ``interactive``, ``pane`` or ``renderer`` were silently + # dropped from vector overlays. + default.update(kwargs) return default diff --git a/tests/test_vector_layers.py b/tests/test_vector_layers.py index 0cb8ba2183..12ad582aa9 100644 --- a/tests/test_vector_layers.py +++ b/tests/test_vector_layers.py @@ -404,3 +404,31 @@ def test_path_options_lower_camel_case(): options = path_options(fill_color="red", fillOpacity=0.3) assert options["fillColor"] == "red" assert options["fillOpacity"] == 0.3 + + +def test_path_options_passes_through_extra_leaflet_options(): + """Leaflet Path options not named explicitly should not be dropped. + + ``interactive``, ``pane``, ``renderer`` and friends used to vanish from + vector overlays even though the other folium option builders forward + arbitrary **kwargs to Leaflet. + """ + options = path_options( + line=False, + radius=10, + interactive=False, + pane="overlayPane", + custom_option="x", + ) + assert options["interactive"] is False + assert options["pane"] == "overlayPane" + # snake_case is camelised like the named options + assert options["customOption"] == "x" + + +def test_circle_marker_forwards_interactive(): + m = Map() + marker = CircleMarker(location=[0, 0], radius=5, interactive=False) + marker.add_to(m) + rendered = normalize(m._parent.render()) + assert '"interactive": false' in rendered