diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 7bb37bd18c..d67a960677 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -93,7 +93,7 @@ angular.module('ui.bootstrap.dropdown', []) } setIsOpen($scope, isOpen); - if (angular.isDefined(wasOpen) && isOpen !== wasOpen) { + if (angular.isDefined(isOpen) && isOpen !== wasOpen) { toggleInvoker($scope, { open: !!isOpen }); } }); diff --git a/src/dropdown/test/dropdown.spec.js b/src/dropdown/test/dropdown.spec.js index d0bf45a2bd..c65f8305e6 100644 --- a/src/dropdown/test/dropdown.spec.js +++ b/src/dropdown/test/dropdown.spec.js @@ -253,4 +253,24 @@ describe('dropdownToggle', function() { expect($rootScope.toggleHandler).toHaveBeenCalledWith(true); }); }); + + describe('`on-toggle` without is-open', function() { + beforeEach(function() { + $rootScope.toggleHandler = jasmine.createSpy('toggleHandler'); + element = $compile('')($rootScope); + $rootScope.$digest(); + }); + + it('should not have been called initially', function() { + expect($rootScope.toggleHandler).not.toHaveBeenCalled(); + }); + + it('should call it when clicked', function() { + clickDropdownToggle(); + expect($rootScope.toggleHandler).toHaveBeenCalledWith(true); + + clickDropdownToggle(); + expect($rootScope.toggleHandler).toHaveBeenCalledWith(false); + }); + }); });