Skip to content

IE11: When document.activeElement is not an HTML element in IFrame, the rendering fails #2531

@ttosev

Description

@ttosev

When using IFrame in IE11 and the document.activeElement is not an HTML element (it is [object { }]), the error is thrown and the rendering of the page inside of IFrame is aborted. This error doesn't appear in version knockout-3.4.0.

Expected Behaviour

No error occurs, the rendering shouldn't be affected if document.activeElement is not an HTML element.

Current Behaviour

No matter the type of document.activeElement, knockout invokes focus which stops rendering and the page gets stuck. The following error appears in the console:

SCRIPT438: Object doesn't support property or method 'focus'
knockout-3.5.1.js (2932,64)

Possible Solution

In knockout-3.5.1 change line:
P&&e.ownerDocument.activeElement!=P&&P.focus();
to
P&&e.ownerDocument.activeElement!=P&&Object.keys(P).length!==0&&P.constructor===Object)&&P.focus();
And in knockout-3.5.1.debug.js change IF in line 6477
if (activeElement && domNode.ownerDocument.activeElement != activeElement)
to
if (activeElement && domNode.ownerDocument.activeElement != activeElement && Object.keys(activeElement).length !== 0 && activeElement.constructor === Object)

Your Environment

  • Version used: knockout-3.5.1
  • Browser: IE11 with an app inside of an IFrame

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions