Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: self-closing iframes is not a thing (#1293)

Myles Scolnickc6a326a9a335
diff --git a/marimo/_output/builder.py b/marimo/_output/builder.py
index 70d1d78887..cf5307c8f9 100644
--- a/marimo/_output/builder.py
+++ b/marimo/_output/builder.py
@@ -69,9 +69,9 @@ class _HTMLBuilder:
params.append(("loop", ""))
if len(params) == 0:
- return "<video />"
+ return "<video></video>"
else:
- return f"<video {_join_params(params)} />"
+ return f"<video {_join_params(params)}></video>"
@staticmethod
def audio(
@@ -86,9 +86,9 @@ class _HTMLBuilder:
params.append(("controls", ""))
if len(params) == 0:
- return "<audio />"
+ return "<audio></audio>"
else:
- return f"<audio {_join_params(params)} />"
+ return f"<audio {_join_params(params)}></audio>"
@staticmethod
def iframe(
@@ -122,9 +122,9 @@ class _HTMLBuilder:
params.append((key, value))
if len(params) == 0:
- return "<iframe />"
+ return "<iframe></iframe>"
else:
- return f"<iframe {_join_params(params)} />"
+ return f"<iframe {_join_params(params)}></iframe>"
@staticmethod
def pre(child: str, style: Optional[str] = None) -> str:
diff --git a/marimo/_smoke_tests/bugs/1291.py b/marimo/_smoke_tests/bugs/1291.py
new file mode 100644
index 0000000000..8a826d86f3
--- /dev/null
+++ b/marimo/_smoke_tests/bugs/1291.py
@@ -0,0 +1,52 @@
+import marimo
+
+__generated_with = "0.4.9"
+app = marimo.App()
+
+
+def __():
+ import marimo as mo
+ import altair as alt
+ import polars as pl
+
+ counts = pl.DataFrame(
+ {
+ "category": ["C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11"],
+ "count": [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],
+ }
+ )
+
+ chart1 = (
+ alt.Chart(counts.to_pandas())
+ .encode(
+ y="count",
+ x=alt.X(
+ "category",
+ ),
+ )
+ .mark_bar(color="blue")
+ )
+
+ chart2 = (
+ alt.Chart(counts.to_pandas())
+ .encode(
+ y="count",
+ x=alt.X(
+ "category",
+ ),
+ )
+ .mark_bar(color="red")
+ )
+
+ mo.vstack(
+ [
+ chart1,
+ chart2
+ ]
+ )
+ return alt, chart1, chart2, counts, mo, pl
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/tests/_output/test_builder.py b/tests/_output/test_builder.py
index ec93422531..dee156eda2 100644
--- a/tests/_output/test_builder.py
+++ b/tests/_output/test_builder.py
@@ -22,24 +22,26 @@ def test_img() -> None:
def test_video() -> None:
- assert h.video() == "<video controls />"
+ assert h.video() == "<video controls></video>"
assert (
- h.video(src="video.mp4", controls=False) == "<video src='video.mp4' />"
+ h.video(src="video.mp4", controls=False)
+ == "<video src='video.mp4'></video>"
)
def test_audio() -> None:
- assert h.audio() == "<audio controls />"
+ assert h.audio() == "<audio controls></audio>"
assert (
- h.audio(src="audio.mp3", controls=False) == "<audio src='audio.mp3' />"
+ h.audio(src="audio.mp3", controls=False)
+ == "<audio src='audio.mp3'></audio>"
)
def test_iframe() -> None:
- assert h.iframe() == "<iframe frameborder='0' />"
+ assert h.iframe() == "<iframe frameborder='0'></iframe>"
assert (
h.iframe(src="https://marimo.io")
- == "<iframe src='https://marimo.io' frameborder='0' />"
+ == "<iframe src='https://marimo.io' frameborder='0'></iframe>"
)