Skip to content

Fix malformed fullscreen attributes on the height-set Figure iframe - #235

Open
Htet-Kaung-San wants to merge 1 commit into
python-visualization:mainfrom
Htet-Kaung-San:fix/iframe-fullscreen-attrs
Open

Fix malformed fullscreen attributes on the height-set Figure iframe#235
Htet-Kaung-San wants to merge 1 commit into
python-visualization:mainfrom
Htet-Kaung-San:fix/iframe-fullscreen-attrs

Conversation

@Htet-Kaung-San

Copy link
Copy Markdown

Figure._repr_html_ builds its iframe two ways. When height is None it emits the fullscreen attributes correctly:

<iframe srcdoc=""  allowfullscreen webkitallowfullscreen mozallowfullscreen>

but when a height is set, the other branch wrapped each in quotes:

<iframe srcdoc="" width="100%" height="400px"style="" "allowfullscreen" "webkitallowfullscreen" "mozallowfullscreen">

Parsing the two outputs with html.parser shows the difference:

fullscreen attribute names
Figure()._repr_html_() allowfullscreen, webkitallowfullscreen, mozallowfullscreen
Figure(height="400px")._repr_html_() "allowfullscreen", "webkitallowfullscreen", "mozallowfullscreen"

The names come out with literal quote characters, so a browser treats them as invalid attributes and ignores them — fullscreen does not work whenever a height is given. The same branch is also missing the space before style, producing height="400px"style="…".

This makes the height branch emit the attributes the same way as the height-less one. The two outputs are then identical apart from width/height.

Testing

Added tests/test_element.py, which parses the rendered iframe and asserts the three boolean attributes are present as real attributes, both with and without a height. The height case fails on main and passes here; the no-height case is the control and passes either way.

black, flake8 --max-line-length=105 --ignore=E203,W503 and isort --profile black are clean. I put the test in a new tests/test_element.py rather than tests/test_iframe.py so it runs without Selenium — it's a pure string/HTML-parsing check.

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant