File tree 2 files changed +15
-10
lines changed
test/unit/angular/directive
2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 1
- var ITEM_TPL_CONTENT_ANCHOR =
2
- '<a class="item-content" ng-href="{{$href()}}" target="{{$target()}}"></a>' ;
3
- var ITEM_TPL_CONTENT =
4
- '<div class="item-content"></div>' ;
5
1
/**
6
2
* @ngdoc directive
7
3
* @name ionItem
@@ -45,11 +41,20 @@ IonicModule
45
41
/ i o n - ( d e l e t e | o p t i o n | r e o r d e r ) - b u t t o n / i. test ( $element . html ( ) ) ;
46
42
47
43
if ( isComplexItem ) {
48
- var innerElement = jqLite ( isAnchor ? ITEM_TPL_CONTENT_ANCHOR : ITEM_TPL_CONTENT ) ;
44
+ var innerElement = jqLite ( isAnchor ? '<a></a>' : '<div></div>' ) ;
45
+ innerElement . addClass ( 'item-content' ) ;
46
+
47
+ if ( isDefined ( $attrs . href ) || isDefined ( $attrs . ngHref ) ) {
48
+ innerElement . attr ( 'ng-href' , '{{$href()}}' )
49
+ if ( isDefined ( $attrs . target ) ) {
50
+ innerElement . attr ( 'target' , '{{$target()}}' )
51
+ }
52
+ }
53
+
49
54
innerElement . append ( $element . contents ( ) ) ;
50
55
51
- $element . append ( innerElement ) ;
52
- $element . addClass ( 'item item-complex' ) ;
56
+ $element . addClass ( 'item item-complex' )
57
+ . append ( innerElement ) ;
53
58
} else {
54
59
$element . addClass ( 'item' ) ;
55
60
}
@@ -59,7 +64,7 @@ IonicModule
59
64
return $attrs . href || $attrs . ngHref ;
60
65
} ;
61
66
$scope . $target = function ( ) {
62
- return $attrs . target || '_self' ;
67
+ return $attrs . target ;
63
68
} ;
64
69
65
70
var content = $element [ 0 ] . querySelector ( '.item-content' ) ;
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ describe('ionItem directive', function() {
34
34
expect ( el . children ( ) . attr ( 'href' ) ) . toBe ( 'something/44' ) ;
35
35
} ) ;
36
36
} ) ;
37
- it ( 'complex item should have target self by default' , function ( ) {
37
+ it ( 'complex item should not have target by default' , function ( ) {
38
38
var el = setup ( 'href="foo"' ) ;
39
- expect ( el . find ( 'a' ) . attr ( 'target' ) ) . toBe ( '_self' ) ;
39
+ expect ( el . find ( 'a' ) . attr ( 'target' ) ) . toBeUndefined ( ) ;
40
40
} ) ;
41
41
it ( 'complex item should have target if specified' , function ( ) {
42
42
var el = setup ( 'href="foo" target="bar"' ) ;
You can’t perform that action at this time.
0 commit comments