Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE11: when document.activeElement is not an HTML element, the rendering fails #1983

Closed
mpfau opened this issue Oct 4, 2017 · 2 comments · Fixed by #2181
Closed

IE11: when document.activeElement is not an HTML element, the rendering fails #1983

mpfau opened this issue Oct 4, 2017 · 2 comments · Fixed by #2181

Comments

@mpfau
Copy link
Contributor

mpfau commented Oct 4, 2017

In case document.activeElement is not an HTML element (e.g. an SVG), the fix from #1943 still fails as focus can only be called on an HTML element.

Expected Behavior

No error occurs, the rendering should complete and document.activeElement should not be modified by mithril when it is no HTML element

Current Behavior

mithril invokes document.activeElement.focus() no matter if the element is an HTML element. The following error is thrown and the rendering is aborted:
TypeError: Object doesn't support property or method 'focus'

Possible Solution

Change https://github.com/MithrilJS/mithril.js/blob/next/render/render.js#L647 to:
if (active != null && $doc.activeElement !== active && active instanceof HTMLElement) active.focus()

Steps to Reproduce (for bugs)

Click on an svg that triggers document.activeElement = svg

Your Environment

  • Version used: mitril-1.1.4
  • Browser Name and version: IE 11
  • Operating System and version (desktop or mobile): Win10 desktop & mobile
@pygy
Copy link
Member

pygy commented Oct 4, 2017

@mpfau thanks for the report. I suppose we should strive for homogenous behavior and implement your suggestion, though my fingers are burning to use typeof active.focus === 'function' instead...

@gamb
Copy link

gamb commented Mar 20, 2018

I'm coming up against this. Mithril 1.1.6 on IE11.

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 a pull request may close this issue.

3 participants