This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ angular.module('ui.bootstrap.dropdown', [])
29
29
} ;
30
30
31
31
var closeDropdown = function ( evt ) {
32
+ // This method may still be called during the same mouse event that
33
+ // unbound this event handler. So check openScope before proceeding.
34
+ if ( ! openScope ) { return ; }
35
+
32
36
var toggleElement = openScope . getToggleElement ( ) ;
33
37
if ( evt && toggleElement && toggleElement [ 0 ] . contains ( evt . target ) ) {
34
38
return ;
Original file line number Diff line number Diff line change @@ -168,6 +168,33 @@ describe('dropdownToggle', function() {
168
168
} ) ;
169
169
} ) ;
170
170
171
+ describe ( 'integration with $location URL rewriting' , function ( ) {
172
+ function dropdown ( ) {
173
+
174
+ // Simulate URL rewriting behavior
175
+ $document . on ( 'click' , 'a[href="#something"]' , function ( ) {
176
+ $rootScope . $broadcast ( '$locationChangeSuccess' ) ;
177
+ $rootScope . $apply ( ) ;
178
+ } ) ;
179
+
180
+ return $compile ( '<li dropdown><a href dropdown-toggle></a>' +
181
+ '<ul><li><a href="#something">Hello</a></li></ul></li>' ) ( $rootScope ) ;
182
+ }
183
+
184
+ beforeEach ( function ( ) {
185
+ element = dropdown ( ) ;
186
+ } ) ;
187
+
188
+ it ( 'should close without errors on $location change' , function ( ) {
189
+ $document . find ( 'body' ) . append ( element ) ;
190
+ clickDropdownToggle ( ) ;
191
+ expect ( element . hasClass ( 'open' ) ) . toBe ( true ) ;
192
+ var optionEl = element . find ( 'ul > li' ) . eq ( 0 ) . find ( 'a' ) . eq ( 0 ) ;
193
+ optionEl . click ( ) ;
194
+ expect ( element . hasClass ( 'open' ) ) . toBe ( false ) ;
195
+ } ) ;
196
+ } ) ;
197
+
171
198
describe ( 'without trigger' , function ( ) {
172
199
beforeEach ( function ( ) {
173
200
$rootScope . isopen = true ;
You can’t perform that action at this time.
0 commit comments