From 4e8d00f8012eda5916c9b74efd23e57ade1bb969 Mon Sep 17 00:00:00 2001 From: hksamm Date: Sun, 23 Aug 2026 02:26:23 +0900 Subject: [PATCH] Fix malformed fullscreen attributes on Figure iframe with a height Figure._repr_html_ has two iframe templates. The one used when height is None emits the bare boolean attributes allowfullscreen webkitallowfullscreen mozallowfullscreen but the one used when a height is set wrapped each in quotes: "allowfullscreen" "webkitallowfullscreen" "mozallowfullscreen" so the attribute names came out with literal quote characters around them and browsers ignored all three -- fullscreen did not work whenever a height was given. The same branch was also missing the space before the style attribute, giving height="..."style="...". Emit the attributes the same way as the height-less branch. Output is now identical to that branch apart from the width/height. Co-Authored-By: Claude Opus 5 --- branca/element.py | 4 ++-- tests/test_element.py | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/test_element.py diff --git a/branca/element.py b/branca/element.py index 853ca16..e6f0571 100644 --- a/branca/element.py +++ b/branca/element.py @@ -425,9 +425,9 @@ def _repr_html_(self, **kwargs) -> str: ).format(html=html, width=self.width, ratio=self.ratio) else: iframe = ( - '" ).format(html=html, width=self.width, height=self.height) return iframe diff --git a/tests/test_element.py b/tests/test_element.py new file mode 100644 index 0000000..846619f --- /dev/null +++ b/tests/test_element.py @@ -0,0 +1,44 @@ +""" +Tests for branca.element +------------------------ +""" + +from html.parser import HTMLParser + +import branca.element as elem + + +class _IframeAttrs(HTMLParser): + """Collect the attributes of every