@@ -5453,7 +5453,7 @@ describe('$compile', function() {
5453
5453
5454
5454
this . $onChanges = function ( changes ) {
5455
5455
if ( changes . input ) {
5456
- log . push ( [ '$onChanges' , changes . input ] ) ;
5456
+ log . push ( [ '$onChanges' , copy ( changes . input ) ] ) ;
5457
5457
}
5458
5458
} ;
5459
5459
}
@@ -5482,6 +5482,53 @@ describe('$compile', function() {
5482
5482
} ) ;
5483
5483
} ) ;
5484
5484
5485
+ it ( 'should not update isolate again after $onInit if outer object reference has not changed' , function ( ) {
5486
+ module ( 'owComponentTest' ) ;
5487
+ inject ( function ( ) {
5488
+ $rootScope . name = [ 'outer' ] ;
5489
+ compile ( '<ow-component input="name"></ow-component>' ) ;
5490
+
5491
+ expect ( $rootScope . name ) . toEqual ( [ 'outer' ] ) ;
5492
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5493
+
5494
+ $rootScope . name [ 0 ] = 'inner' ;
5495
+ $rootScope . $digest ( ) ;
5496
+
5497
+ expect ( $rootScope . name ) . toEqual ( [ 'inner' ] ) ;
5498
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5499
+
5500
+ expect ( log ) . toEqual ( [
5501
+ 'constructor' ,
5502
+ [ '$onChanges' , jasmine . objectContaining ( { currentValue : [ 'outer' ] } ) ] ,
5503
+ '$onInit'
5504
+ ] ) ;
5505
+ } ) ;
5506
+ } ) ;
5507
+
5508
+ it ( 'should update isolate again after $onInit if outer object reference changes even if equal' , function ( ) {
5509
+ module ( 'owComponentTest' ) ;
5510
+ inject ( function ( ) {
5511
+ $rootScope . name = [ 'outer' ] ;
5512
+ compile ( '<ow-component input="name"></ow-component>' ) ;
5513
+
5514
+ expect ( $rootScope . name ) . toEqual ( [ 'outer' ] ) ;
5515
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5516
+
5517
+ $rootScope . name = [ 'outer' ] ;
5518
+ $rootScope . $digest ( ) ;
5519
+
5520
+ expect ( $rootScope . name ) . toEqual ( [ 'outer' ] ) ;
5521
+ expect ( component . input ) . toEqual ( [ 'outer' ] ) ;
5522
+
5523
+ expect ( log ) . toEqual ( [
5524
+ 'constructor' ,
5525
+ [ '$onChanges' , jasmine . objectContaining ( { currentValue : [ 'outer' ] } ) ] ,
5526
+ '$onInit' ,
5527
+ [ '$onChanges' , jasmine . objectContaining ( { previousValue : [ 'outer' ] , currentValue : [ 'outer' ] } ) ]
5528
+ ] ) ;
5529
+ } ) ;
5530
+ } ) ;
5531
+
5485
5532
it ( 'should not update isolate again after $onInit if outer is a literal' , function ( ) {
5486
5533
module ( 'owComponentTest' ) ;
5487
5534
inject ( function ( ) {
0 commit comments