Skip to content

Commit 3a2afb1

Browse files
hansthenConengmo
andauthored
Cleanup make MacroElements from Elements (#2066)
* Cleanup make MacroElements from Elements This change involves several classes that require being added to a Figure. Since these classes follow the `render` semantics of a MacroElement it makes more sense to make them also inherit from MacroElement. Excluded from this change is actually making use of the template mechanics of the MacroElement. * Fix missing import * Update folium/features.py Co-authored-by: Frank Anema <[email protected]> * Update folium/features.py Co-authored-by: Frank Anema <[email protected]> --------- Co-authored-by: Frank Anema <[email protected]>
1 parent 29062dd commit 3a2afb1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

folium/elements.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
from typing import List, Tuple
22

3-
from branca.element import CssLink, Element, Figure, JavascriptLink, MacroElement
3+
from branca.element import (
4+
CssLink,
5+
Element, # NoQA: F401 needed as a reexport
6+
Figure,
7+
JavascriptLink,
8+
MacroElement,
9+
)
410

511
from folium.template import Template
612
from folium.utilities import JsCode
713

814

9-
class JSCSSMixin(Element):
15+
class JSCSSMixin(MacroElement):
1016
"""Render links to external Javascript and CSS resources."""
1117

1218
default_js: List[Tuple[str, str]] = []

folium/features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __init__(
111111
)
112112

113113

114-
class Vega(JSCSSMixin, Element):
114+
class Vega(JSCSSMixin):
115115
"""
116116
Creates a Vega chart element.
117117
@@ -234,7 +234,7 @@ def render(self, **kwargs):
234234
)
235235

236236

237-
class VegaLite(Element):
237+
class VegaLite(MacroElement):
238238
"""
239239
Creates a Vega-Lite chart element.
240240

folium/map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def render(self):
433433
super().render()
434434

435435

436-
class Popup(Element):
436+
class Popup(MacroElement):
437437
"""Create a Popup instance that can be linked to a Layer.
438438
439439
Parameters

0 commit comments

Comments
 (0)