File tree 3 files changed +34
-9
lines changed
3 files changed +34
-9
lines changed Original file line number Diff line number Diff line change 16
16
var htmlAnchorDirective = valueFn ( {
17
17
restrict : 'E' ,
18
18
compile : function ( element , attr ) {
19
- // turn <a href ng-click="..">link</a> into a link in IE
20
- // but only if it doesn't have name attribute, in which case it's an anchor
21
- if ( ! attr . href ) {
22
- attr . $set ( 'href' , '' ) ;
19
+
20
+ if ( msie <= 8 ) {
21
+
22
+ // turn <a href ng-click="..">link</a> into a stylable link in IE
23
+ // but only if it doesn't have name attribute, in which case it's an anchor
24
+ if ( ! attr . href && ! attr . name ) {
25
+ attr . $set ( 'href' , '' ) ;
26
+ }
27
+
28
+ // add a comment node to anchors to workaround IE bug that causes element content to be reset
29
+ // to new attribute content if attribute is updated with value containing @ and element also
30
+ // contains value with @
31
+ // see issue #1949
32
+ element . append ( document . createComment ( 'IE fix' ) ) ;
23
33
}
24
34
25
35
return function ( scope , element ) {
Original file line number Diff line number Diff line change 66
66
it('should execute ng-click but not reload when no href but name specified', function() {
67
67
element('#link-5').click();
68
68
expect(input('value').val()).toEqual('5');
69
- expect(element('#link-5').attr('href')).toBe('' );
69
+ expect(element('#link-5').attr('href')).toBe(undefined );
70
70
});
71
71
72
72
it('should only change url when only ng-href', function() {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
describe ( 'a' , function ( ) {
4
- var element ;
4
+ var element , $compile , $rootScope ;
5
+
6
+
7
+ beforeEach ( inject ( function ( _$compile_ , _$rootScope_ ) {
8
+ $compile = _$compile_ ;
9
+ $rootScope = _$rootScope_ ;
10
+ } ) ) ;
5
11
6
12
7
13
afterEach ( function ( ) {
8
14
dealoc ( element ) ;
9
15
} ) ;
10
16
11
17
12
- it ( 'should prevent default action to be executed when href is empty' ,
13
- inject ( function ( $rootScope , $compile ) {
18
+ it ( 'should prevent default action to be executed when href is empty' , function ( ) {
14
19
var orgLocation = document . location . href ,
15
20
preventDefaultCalled = false ,
16
21
event ;
@@ -42,5 +47,15 @@ describe('a', function() {
42
47
}
43
48
44
49
expect ( document . location . href ) . toEqual ( orgLocation ) ;
45
- } ) ) ;
50
+ } ) ;
51
+
52
+
53
+ it ( 'should prevent IE for changing text content when setting attribute' , function ( ) {
54
+ // see issue #1949
55
+ element = jqLite ( '<a href="">hello@you</a>' ) ;
56
+ $compile ( element ) ;
57
+ element . attr ( 'href' , 'bye@me' ) ;
58
+
59
+ expect ( element . text ( ) ) . toBe ( 'hello@you' ) ;
60
+ } ) ;
46
61
} ) ;
You can’t perform that action at this time.
0 commit comments