Skip to content

Commit

Permalink
fix(datepicker): add check for contains
Browse files Browse the repository at this point in the history
  • Loading branch information
yjukaku authored and jasonaden committed Sep 30, 2015
1 parent 740c15c commit 61f4bef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 61f4bef

Please sign in to comment.