From 868c0e248d28a3cdc98d47fb772c22a1a97c6db9 Mon Sep 17 00:00:00 2001 From: Yousuf Jukaku Date: Wed, 16 Sep 2015 10:23:33 -0400 Subject: [PATCH] fix(datepicker): add check for `contains` Closes #4423 Fixes #4411 --- src/datepicker/datepicker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index d17a95ff7b..f6c35cd137 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -713,7 +713,12 @@ function($compile, $parse, $document, $rootScope, $position, dateFilter, datePar }); var documentClickBind = function(event) { - if (scope.isOpen && !(element[0].contains(event.target) || $popup[0].contains(event.target))) { + var popup = $popup[0]; + var dpContainsTarget = element[0].contains(event.target); + // The popup node may not be an element node + // In some browsers (IE) only element nodes have the 'contains' function + var popupContainsTarget = popup.contains !== undefined && popup.contains(event.target); + if (scope.isOpen && !(dpContainsTarget || popupContainsTarget)) { scope.$apply(function() { scope.isOpen = false; });