File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -641,6 +641,13 @@ function $LocationProvider(){
641
641
if ( elm [ 0 ] === $rootElement [ 0 ] || ! ( elm = elm . parent ( ) ) [ 0 ] ) return ;
642
642
}
643
643
644
+ var href = elm . attr ( 'href' ) || elm . attr ( 'xlink:href' ) ;
645
+
646
+ if ( href && href . indexOf ( '#' + hashPrefix ) !== 0 && href [ 0 ] === '#' ) {
647
+ // Don't rewrite hash-fragment links in the same document.
648
+ return ;
649
+ }
650
+
644
651
var absHref = elm . prop ( 'href' ) ;
645
652
646
653
if ( isObject ( absHref ) && absHref . toString ( ) === '[object SVGAnimatedString]' ) {
Original file line number Diff line number Diff line change @@ -1164,6 +1164,32 @@ describe('$location', function() {
1164
1164
} ) ;
1165
1165
1166
1166
1167
+ it ( 'should not rewrite when clicking on relative hash fragments' , function ( ) {
1168
+ configureService ( '#foo' , true , true , true ) ;
1169
+ inject (
1170
+ initBrowser ( ) ,
1171
+ initLocation ( ) ,
1172
+ function ( $browser ) {
1173
+ browserTrigger ( link , 'click' ) ;
1174
+ expectNoRewrite ( $browser ) ;
1175
+ }
1176
+ ) ;
1177
+ } ) ;
1178
+
1179
+
1180
+ it ( 'should not rewrite when clicking on relative hash fragments in old browser' , function ( ) {
1181
+ configureService ( '#foo' , true , false , true ) ;
1182
+ inject (
1183
+ initBrowser ( ) ,
1184
+ initLocation ( ) ,
1185
+ function ( $browser ) {
1186
+ browserTrigger ( link , 'click' ) ;
1187
+ expectNoRewrite ( $browser ) ;
1188
+ }
1189
+ ) ;
1190
+ } ) ;
1191
+
1192
+
1167
1193
// don't run next tests on IE<9, as browserTrigger does not simulate pressed keys
1168
1194
if ( ! msie || msie >= 9 ) {
1169
1195
You can’t perform that action at this time.
0 commit comments