@@ -5416,21 +5416,21 @@ describe('$compile', function() {
5416
5416
5417
5417
inject ( function ( $rootScope ) {
5418
5418
compile ( '<div other-tpl-dir param1="::foo" param2="bar"></div>' ) ;
5419
- expect ( countWatches ( $rootScope ) ) . toEqual ( 6 ) ; // 4 -> template watch group, 2 -> '='
5419
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 8 ) ; // 4 -> template watch group, 2 -> '='
5420
5420
$rootScope . $digest ( ) ;
5421
5421
expect ( element . html ( ) ) . toBe ( '1:;2:;3:;4:' ) ;
5422
- expect ( countWatches ( $rootScope ) ) . toEqual ( 6 ) ;
5422
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 8 ) ;
5423
5423
5424
5424
$rootScope . foo = 'foo' ;
5425
5425
$rootScope . $digest ( ) ;
5426
5426
expect ( element . html ( ) ) . toBe ( '1:foo;2:;3:foo;4:' ) ;
5427
- expect ( countWatches ( $rootScope ) ) . toEqual ( 4 ) ;
5427
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 6 ) ;
5428
5428
5429
5429
$rootScope . foo = 'baz' ;
5430
5430
$rootScope . bar = 'bar' ;
5431
5431
$rootScope . $digest ( ) ;
5432
5432
expect ( element . html ( ) ) . toBe ( '1:foo;2:bar;3:foo;4:bar' ) ;
5433
- expect ( countWatches ( $rootScope ) ) . toEqual ( 3 ) ;
5433
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 5 ) ;
5434
5434
5435
5435
$rootScope . bar = 'baz' ;
5436
5436
$rootScope . $digest ( ) ;
@@ -5487,18 +5487,18 @@ describe('$compile', function() {
5487
5487
compile ( '<div other-tpl-dir param1="::foo" param2="bar"></div>' ) ;
5488
5488
$rootScope . $digest ( ) ;
5489
5489
expect ( element . html ( ) ) . toBe ( '1:;2:;3:;4:' ) ;
5490
- expect ( countWatches ( $rootScope ) ) . toEqual ( 6 ) ; // 4 -> template watch group, 2 -> '='
5490
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 8 ) ; // 4 -> template watch group, 2 -> '='
5491
5491
5492
5492
$rootScope . foo = 'foo' ;
5493
5493
$rootScope . $digest ( ) ;
5494
5494
expect ( element . html ( ) ) . toBe ( '1:foo;2:;3:foo;4:' ) ;
5495
- expect ( countWatches ( $rootScope ) ) . toEqual ( 4 ) ;
5495
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 6 ) ;
5496
5496
5497
5497
$rootScope . foo = 'baz' ;
5498
5498
$rootScope . bar = 'bar' ;
5499
5499
$rootScope . $digest ( ) ;
5500
5500
expect ( element . html ( ) ) . toBe ( '1:foo;2:bar;3:foo;4:bar' ) ;
5501
- expect ( countWatches ( $rootScope ) ) . toEqual ( 3 ) ;
5501
+ expect ( countWatches ( $rootScope ) ) . toEqual ( 5 ) ;
5502
5502
5503
5503
$rootScope . bar = 'baz' ;
5504
5504
$rootScope . $digest ( ) ;
@@ -5771,6 +5771,46 @@ describe('$compile', function() {
5771
5771
}
5772
5772
} ) ) ;
5773
5773
5774
+ it ( 'should work with filtered literal objects within array literals' , inject ( function ( ) {
5775
+ $rootScope . gabName = 'Gabriel' ;
5776
+ $rootScope . tonyName = 'Tony' ;
5777
+ $rootScope . query = '' ;
5778
+ $rootScope . $apply ( ) ;
5779
+
5780
+ compile ( '<div><span my-component reference="[{name: gabName}, {name: tonyName}] | filter:query">' ) ;
5781
+
5782
+ expect ( componentScope . reference ) . toEqual ( [ { name : $rootScope . gabName } , { name : $rootScope . tonyName } ] ) ;
5783
+
5784
+ $rootScope . query = 'Gab' ;
5785
+ $rootScope . $apply ( ) ;
5786
+
5787
+ expect ( componentScope . reference ) . toEqual ( [ { name : $rootScope . gabName } ] ) ;
5788
+
5789
+ $rootScope . tonyName = 'Gab' ;
5790
+ $rootScope . $apply ( ) ;
5791
+
5792
+ expect ( componentScope . reference ) . toEqual ( [ { name : $rootScope . gabName } , { name : $rootScope . tonyName } ] ) ;
5793
+ } ) ) ;
5794
+
5795
+ it ( 'should work with filtered constant literal objects within array literals (constant)' , inject ( function ( ) {
5796
+ $rootScope . query = '' ;
5797
+ $rootScope . $apply ( ) ;
5798
+
5799
+ compile ( '<div><span my-component reference="[{name: \'Gabriel\'}, {name: \'Toni\'}] | filter:query">' ) ;
5800
+
5801
+ expect ( componentScope . reference ) . toEqual ( [ { name : 'Gabriel' } , { name : 'Toni' } ] ) ;
5802
+
5803
+ $rootScope . query = 'Gab' ;
5804
+ $rootScope . $apply ( ) ;
5805
+
5806
+ expect ( componentScope . reference ) . toEqual ( [ { name : 'Gabriel' } ] ) ;
5807
+
5808
+ $rootScope . query = 'i' ;
5809
+ $rootScope . $apply ( ) ;
5810
+
5811
+ expect ( componentScope . reference ) . toEqual ( [ { name : 'Gabriel' } , { name : 'Toni' } ] ) ;
5812
+ } ) ) ;
5813
+
5774
5814
} ) ;
5775
5815
5776
5816
} ) ;
@@ -5829,8 +5869,48 @@ describe('$compile', function() {
5829
5869
$rootScope . $apply ( ) ;
5830
5870
5831
5871
expect ( componentScope . colref ) . toEqual ( [ $rootScope . collection [ 0 ] ] ) ;
5832
- expect ( componentScope . colrefAlias ) . toEqual ( [ $rootScope . collection [ 0 ] ] ) ;
5833
- expect ( componentScope . $colrefAlias ) . toEqual ( [ $rootScope . collection [ 0 ] ] ) ;
5872
+ expect ( componentScope . colrefAlias ) . toEqual ( componentScope . colref ) ;
5873
+ expect ( componentScope . $colrefAlias ) . toEqual ( componentScope . colref ) ;
5874
+
5875
+ $rootScope . collection [ 1 ] . name = 'Gab' ;
5876
+ $rootScope . $apply ( ) ;
5877
+
5878
+ expect ( componentScope . colref ) . toEqual ( $rootScope . collection ) ;
5879
+ expect ( componentScope . colrefAlias ) . toEqual ( componentScope . colref ) ;
5880
+ expect ( componentScope . $colrefAlias ) . toEqual ( componentScope . colref ) ;
5881
+ } ) ) ;
5882
+
5883
+ it ( 'should work with filtered objects within a literal collection' , inject ( function ( ) {
5884
+ $rootScope . gab = {
5885
+ name : 'Gabriel' ,
5886
+ value : 18
5887
+ } ;
5888
+ $rootScope . tony = {
5889
+ name : 'Tony' ,
5890
+ value : 91
5891
+ } ;
5892
+ $rootScope . query = '' ;
5893
+ $rootScope . $apply ( ) ;
5894
+
5895
+ compile ( '<div><span my-component colref="[gab, tony] | filter:query" $colref$="[gab, tony] | filter:query">' ) ;
5896
+
5897
+ expect ( componentScope . colref ) . toEqual ( [ $rootScope . gab , $rootScope . tony ] ) ;
5898
+ expect ( componentScope . colrefAlias ) . toEqual ( componentScope . colref ) ;
5899
+ expect ( componentScope . $colrefAlias ) . toEqual ( componentScope . colref ) ;
5900
+
5901
+ $rootScope . query = 'Gab' ;
5902
+ $rootScope . $apply ( ) ;
5903
+
5904
+ expect ( componentScope . colref ) . toEqual ( [ $rootScope . gab ] ) ;
5905
+ expect ( componentScope . colrefAlias ) . toEqual ( componentScope . colref ) ;
5906
+ expect ( componentScope . $colrefAlias ) . toEqual ( componentScope . colref ) ;
5907
+
5908
+ $rootScope . tony . name = 'Gab' ;
5909
+ $rootScope . $apply ( ) ;
5910
+
5911
+ expect ( componentScope . colref ) . toEqual ( [ $rootScope . gab , $rootScope . tony ] ) ;
5912
+ expect ( componentScope . colrefAlias ) . toEqual ( componentScope . colref ) ;
5913
+ expect ( componentScope . $colrefAlias ) . toEqual ( componentScope . colref ) ;
5834
5914
} ) ) ;
5835
5915
5836
5916
it ( 'should update origin scope when isolate scope changes' , inject ( function ( ) {
@@ -6187,6 +6267,47 @@ describe('$compile', function() {
6187
6267
} ) ) ;
6188
6268
6189
6269
6270
+ it ( 'should work with filtered literal objects within array literals' , inject ( function ( ) {
6271
+ $rootScope . gabName = 'Gabriel' ;
6272
+ $rootScope . tonyName = 'Tony' ;
6273
+ $rootScope . query = '' ;
6274
+ $rootScope . $apply ( ) ;
6275
+
6276
+ compile ( '<div><span my-component ow-ref="[{name: gabName}, {name: tonyName}] | filter:query">' ) ;
6277
+
6278
+ expect ( componentScope . owRef ) . toEqual ( [ { name : $rootScope . gabName } , { name : $rootScope . tonyName } ] ) ;
6279
+
6280
+ $rootScope . query = 'Gab' ;
6281
+ $rootScope . $apply ( ) ;
6282
+
6283
+ expect ( componentScope . owRef ) . toEqual ( [ { name : $rootScope . gabName } ] ) ;
6284
+
6285
+ $rootScope . tonyName = 'Gab' ;
6286
+ $rootScope . $apply ( ) ;
6287
+
6288
+ expect ( componentScope . owRef ) . toEqual ( [ { name : $rootScope . gabName } , { name : $rootScope . tonyName } ] ) ;
6289
+ } ) ) ;
6290
+
6291
+ it ( 'should work with filtered constant literal objects within array literals' , inject ( function ( ) {
6292
+ $rootScope . query = '' ;
6293
+ $rootScope . $apply ( ) ;
6294
+
6295
+ compile ( '<div><span my-component ow-ref="[{name: \'Gabriel\'}, {name: \'Toni\'}] | filter:query">' ) ;
6296
+
6297
+ expect ( componentScope . owRef ) . toEqual ( [ { name : 'Gabriel' } , { name : 'Toni' } ] ) ;
6298
+
6299
+ $rootScope . query = 'Gab' ;
6300
+ $rootScope . $apply ( ) ;
6301
+
6302
+ expect ( componentScope . owRef ) . toEqual ( [ { name : 'Gabriel' } ] ) ;
6303
+
6304
+ $rootScope . query = 'i' ;
6305
+ $rootScope . $apply ( ) ;
6306
+
6307
+ expect ( componentScope . owRef ) . toEqual ( [ { name : 'Gabriel' } , { name : 'Toni' } ] ) ;
6308
+ } ) ) ;
6309
+
6310
+
6190
6311
describe ( 'literal objects' , function ( ) {
6191
6312
it ( 'should copy parent changes' , inject ( function ( ) {
6192
6313
compile ( '<div><span my-component ow-ref="{name: name}">' ) ;
0 commit comments