Add a title attribute to rendered iframes for accessibility - #236
Open
Htet-Kaung-San wants to merge 2 commits into
Open
Add a title attribute to rendered iframes for accessibility#236Htet-Kaung-San wants to merge 2 commits into
Htet-Kaung-San wants to merge 2 commits 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>
Accessibility audits flag the iframe that branca renders in notebooks with "frames must have an accessible name" (WCAG 2.1), because the iframe has no title attribute (python-visualization#213). Emit a title attribute when one is available: - Figure reuses its existing title, so Figure(title="...") now names both the document <title> and the iframe. - IFrame gains a title parameter. When no title is set the output is byte-for-byte unchanged, so existing maps are unaffected; the title is HTML-escaped so a value containing a quote cannot break out of the attribute. Builds on python-visualization#235 (both touch the same iframe templates); the net new change here is the title attribute. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Htet-Kaung-San
force-pushed
the
feature/iframe-title-attr
branch
from
August 23, 2026 06:00
42d0672 to
0fe8d36
Compare
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.
Closes #213.
An accessibility audit (axe / WCAG 2.1) of a folium map flags the iframe branca renders in notebooks with "Frames must have an accessible name", because the iframe has no
titleattribute.This emits a
titleattribute when one is available:Figurereuses its existingtitle, soFigure(title="…")now names both the document<title>and the iframe.IFramegains atitleparameter.Design notes:
Figure/IFramewith the attribute code stashed), so existing maps are unaffected. It's opt-in, matching how the issue is framed ("enable adding a title attribute").html.escape, so a title containing a quote can't break out of the attribute.Testing
Five new tests in
tests/test_element.py(title absent by default, set on bothFigureandIFrame, and properly escaped).tests/test_element.pyis 7 passed,tests/test_colormap.pyunaffected.black,flake8 --max-line-length=105 --ignore=E203,W503, andisort --profile blackare clean.