This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 3 files changed +9
-2
lines changed
3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -560,7 +560,7 @@ function createEventHandler(element, events) {
560
560
}
561
561
562
562
event . isDefaultPrevented = function ( ) {
563
- return event . defaultPrevented ;
563
+ return event . defaultPrevented || event . returnValue == false ;
564
564
} ;
565
565
566
566
forEach ( events [ type || event . type ] , function ( fn ) {
Original file line number Diff line number Diff line change @@ -527,7 +527,7 @@ function $LocationProvider(){
527
527
var absHref = elm . prop ( 'href' ) ;
528
528
var rewrittenUrl = $location . $$rewrite ( absHref ) ;
529
529
530
- if ( absHref && ! elm . attr ( 'target' ) && rewrittenUrl ) {
530
+ if ( absHref && ! elm . attr ( 'target' ) && rewrittenUrl && ! event . isDefaultPrevented ( ) ) {
531
531
event . preventDefault ( ) ;
532
532
if ( rewrittenUrl != $browser . url ( ) ) {
533
533
// update location manually
Original file line number Diff line number Diff line change @@ -835,6 +835,12 @@ describe('$location', function() {
835
835
jqLite ( link ) . attr ( 'href' , 'http://host.com/base/' ) ;
836
836
browserTrigger ( link , 'click' ) ;
837
837
expectRewriteTo ( $browser , 'http://host.com/base/' ) ;
838
+
839
+ jqLite ( link ) .
840
+ attr ( 'href' , 'http://host.com/base/foo' ) .
841
+ bind ( 'click' , function ( e ) { e . preventDefault ( ) ; } ) ;
842
+ browserTrigger ( link , 'click' ) ;
843
+ expect ( $browser . url ( ) ) . toBe ( 'http://host.com/base/' ) ;
838
844
}
839
845
) ;
840
846
} ) ;
@@ -1372,6 +1378,7 @@ describe('$location', function() {
1372
1378
expect ( location . $$rewrite ( 'http://other' ) ) . toEqual ( undefined ) ;
1373
1379
expect ( location . $$rewrite ( 'http://server/pre/' ) ) . toEqual ( 'http://server/pre/' ) ;
1374
1380
expect ( location . $$rewrite ( 'http://server/pre/#otherPath' ) ) . toEqual ( 'http://server/pre/#otherPath' ) ;
1381
+ expect ( location . $$rewrite ( 'javascript:void(0)' ) ) . toEqual ( undefined ) ;
1375
1382
} ) ;
1376
1383
} ) ;
1377
1384
You can’t perform that action at this time.
0 commit comments