Skip to content

Add accessible iframe titles and document language - #250

Open
29-5-RafayKhattak wants to merge 1 commit into
python-visualization:mainfrom
29-5-RafayKhattak:rk/accessible-iframes
Open

29-5-RafayKhattak wants to merge 1 commit into
python-visualization:mainfrom
29-5-RafayKhattak:rk/accessible-iframes

Conversation

@29-5-RafayKhattak

Copy link
Copy Markdown

What changed

  • use a Figure title as the accessible name of its notebook iframe
  • add an optional title argument to IFrame
  • escape iframe title attributes before rendering
  • add a configurable lang attribute to generated Figure documents, defaulting to en
  • add regression tests for the rendered accessibility attributes

This lets Folium users write map.get_root().title = "Map description" and get both a document title and an accessible iframe name.

Closes #213.

Tests

  • pytest tests/test_accessibility.py (2 passed)
  • non-browser suite excluding the existing slow test_color_brewer_extendability test (34 passed)
  • flake8
  • black --check
  • isort --check-only
  • codespell
  • mypy branca

@nk-batman21

Copy link
Copy Markdown

There’s an upgrade case for the two new attributes. I saved an IFrame and a Figure with Branca 0.8.2, then loaded them in a separate process on 2145813. Both unpickle successfully. Rendering the old IFrame raises AttributeError: 'IFrame' object has no attribute 'title' (with either a fixed height or the default responsive layout). The old Figure renders <html lang="">, whereas a newly constructed figure gets lang="en".

Element.__setstate__ restores the saved attributes without running the constructor. I tried class-level defaults of IFrame.title = None and Figure.lang = "en" alongside the existing constructor assignments: both old iframe layouts rendered and the old figure picked up en. Could we cover missing attributes from an older saved object in the accessibility tests?

This branch has not been deployed

No deployments
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.

Accessibility issue - possible to enable adding HTML attributes to rendered iframe elements?

2 participants