Fix malformed fullscreen attributes on the height-set Figure iframe - #235
Open
Htet-Kaung-San wants to merge 1 commit into
Open
Fix malformed fullscreen attributes on the height-set Figure iframe#235Htet-Kaung-San wants to merge 1 commit into
Htet-Kaung-San wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Figure._repr_html_builds its iframe two ways. WhenheightisNoneit emits the fullscreen attributes correctly:but when a
heightis set, the other branch wrapped each in quotes:Parsing the two outputs with
html.parsershows the difference:Figure()._repr_html_()allowfullscreen,webkitallowfullscreen,mozallowfullscreenFigure(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, producingheight="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 onmainand passes here; the no-height case is the control and passes either way.black,flake8 --max-line-length=105 --ignore=E203,W503andisort --profile blackare clean. I put the test in a newtests/test_element.pyrather thantests/test_iframe.pyso it runs without Selenium — it's a pure string/HTML-parsing check.