Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup make MacroElements from Elements #2066

Merged
merged 4 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions folium/elements.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
from typing import List, Tuple

from branca.element import CssLink, Element, Figure, JavascriptLink, MacroElement
from branca.element import (
CssLink,
Element, # NoQA: F401 needed as a reexport
Figure,
JavascriptLink,
MacroElement,
)

from folium.template import Template
from folium.utilities import JsCode


class JSCSSMixin(Element):
class JSCSSMixin(MacroElement):
"""Render links to external Javascript and CSS resources."""

default_js: List[Tuple[str, str]] = []
Expand Down
4 changes: 2 additions & 2 deletions folium/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(
)


class Vega(JSCSSMixin, Element):
class Vega(JSCSSMixin):
"""
Creates a Vega chart element.

Expand Down Expand Up @@ -224,7 +224,7 @@ def render(self, **kwargs) -> None:
)


class VegaLite(Element):
class VegaLite(MacroElement):
"""
Creates a Vega-Lite chart element.

Expand Down
2 changes: 1 addition & 1 deletion folium/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def render(self) -> None:
super().render()


class Popup(Element):
class Popup(MacroElement):
"""Create a Popup instance that can be linked to a Layer.

Parameters
Expand Down
Loading