Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 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 @@ -193,6 +193,8 @@ def render(self, **kwargs) -> None:
name=self.get_name(),
)

# TODO: this could be rewritten to use the facilities of MacroElement
# and the facilities of JSCSSMixin
figure = self.get_root()
assert isinstance(
figure, Figure
Expand Down Expand Up @@ -224,7 +226,7 @@ def render(self, **kwargs) -> None:
)


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

Expand Down Expand Up @@ -297,6 +299,9 @@ def render(self, **kwargs) -> None:
name=self.get_name(),
)

# TODO: this could be rewritten to use the facilities of MacroElement
# and the facilities of JSCSSMixin

figure = self.get_root()
assert isinstance(
figure, Figure
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