Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Object doesn't support property or method 'focus' #5390

Closed
antonabramovich opened this issue Feb 2, 2016 · 1 comment
Closed

Object doesn't support property or method 'focus' #5390

antonabramovich opened this issue Feb 2, 2016 · 1 comment

Comments

@antonabramovich
Copy link

This error happens in IE11 if I try to do $uibModalInstance.dismiss() when using only jqLite (without jQuery):

at removeModalWindow (http://localhost:8000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:3781:11)
at $modalStack.dismiss (http://localhost:8000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:3962:11)
at modalInstance.dismiss (http://localhost:8000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:4083:17)

This is caused by the following line of code:

     //move focus to specified element if available, or else to body

    if (elementToReceiveFocus && elementToReceiveFocus.focus) {

      elementToReceiveFocus.focus();

    } else {

      body.focus();

    }

So body doesn't support .focus() method in IE, because it is a jqLite object, not DOM element.
It seems eq(0) before that does nothing in case of jqLite.

@antonabramovich
Copy link
Author

Original issue #5096

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant