@@ -13,9 +13,27 @@ describe('ngNonBindable', function() {
13
13
it ( 'should prevent compilation of the owning element and its children' ,
14
14
inject ( function ( $rootScope , $compile ) {
15
15
element = $compile ( '<div ng-non-bindable text="{{name}}"><span ng-bind="name"></span></div>' ) ( $rootScope ) ;
16
- $rootScope . name = 'misko' ;
16
+ element = $compile ( '<div>' +
17
+ ' <span id="s1">{{a}}</span>' +
18
+ ' <span id="s2" ng-bind="b"></span>' +
19
+ ' <div foo="{{a}}" ng-non-bindable>' +
20
+ ' <span ng-bind="a"></span>{{b}}' +
21
+ ' </div>' +
22
+ ' <span id="s3">{{a}}</span>' +
23
+ ' <span id="s4" ng-bind="b"></span>' +
24
+ '</div>' ) ( $rootScope ) ;
25
+ $rootScope . a = "one" ;
26
+ $rootScope . b = "two" ;
17
27
$rootScope . $digest ( ) ;
18
- expect ( element . text ( ) ) . toEqual ( '' ) ;
19
- expect ( element . attr ( 'text' ) ) . toEqual ( '{{name}}' ) ;
28
+ // Bindings not contained by ng-non-bindable should resolve.
29
+ var spans = element . find ( "span" ) ;
30
+ expect ( spans . eq ( 0 ) . text ( ) ) . toEqual ( 'one' ) ;
31
+ expect ( spans . eq ( 1 ) . text ( ) ) . toEqual ( 'two' ) ;
32
+ expect ( spans . eq ( 3 ) . text ( ) ) . toEqual ( 'one' ) ;
33
+ expect ( spans . eq ( 4 ) . text ( ) ) . toEqual ( 'two' ) ;
34
+ // Bindings contained by ng-non-bindable should be left alone.
35
+ var nonBindableDiv = element . find ( "div" ) ;
36
+ expect ( nonBindableDiv . attr ( 'foo' ) ) . toEqual ( '{{a}}' ) ;
37
+ expect ( trim ( nonBindableDiv . text ( ) ) ) . toEqual ( '{{b}}' ) ;
20
38
} ) ) ;
21
39
} ) ;
0 commit comments