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.
No error occurs, the rendering should complete and document.activeElement should not be modified by mithril when it is no HTML element
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'
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()
Click on an svg that triggers document.activeElement = svg
@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...
I'm coming up against this. Mithril 1.1.6 on IE11.
Most helpful comment
@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...