From 5df696be74f98a1f7595e7b1296e091f559b8bbd Mon Sep 17 00:00:00 2001 From: Anthony Cheung Date: Fri, 7 Oct 2016 12:09:09 -0400 Subject: [PATCH] fix(dropdown): added null check to .focus & .contains --- src/dropdown/dropdown.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 3383c904d6..858c49b481 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -38,13 +38,13 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) if (evt && evt.which === 3) { return; } var toggleElement = openScope.getToggleElement(); - if (evt && toggleElement && toggleElement[0].contains(evt.target)) { + if (evt && toggleElement && toggleElement[0].contains && toggleElement[0].contains(evt.target)) { return; } var dropdownElement = openScope.getDropdownElement(); if (evt && openScope.getAutoClose() === 'outsideClick' && - dropdownElement && dropdownElement[0].contains(evt.target)) { + dropdownElement && dropdownElement[0].contains && dropdownElement[0].contains(evt.target)) { return; } @@ -186,7 +186,8 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) }; scope.focusToggleElement = function() { - if (self.toggleElement) { + // Add a null check to .focus here. Some elements, such as svg in IE, may not have focus + if (self.toggleElement && self.toggleElement[0].focus) { self.toggleElement[0].focus(); } };