@@ -5403,7 +5403,7 @@ describe('$compile', function() {
5403
5403
5404
5404
this . $onChanges = function ( changes ) {
5405
5405
if ( changes . input ) {
5406
- log . push ( [ '$onChanges' , changes . input ] ) ;
5406
+ log . push ( [ '$onChanges' , copy ( changes . input ) ] ) ;
5407
5407
}
5408
5408
} ;
5409
5409
}
@@ -5432,6 +5432,53 @@ describe('$compile', function() {
5432
5432
} ) ;
5433
5433
} ) ;
5434
5434
5435
+ it ( 'should not update isolate again after $onInit if outer object reference has not changed' , function ( ) {
5436
+ module ( 'owComponentTest' ) ;
5437
+ inject ( function ( ) {
5438
+ $rootScope . name = [ 'outer' ] ;
5439
+ compile ( '<ow-component input="name"></ow-component>' ) ;
5440
+
5441
+ expect ( $rootScope . name ) . toEqual ( [ 'outer' ] ) ;
5442
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5443
+
5444
+ $rootScope . name [ 0 ] = 'inner' ;
5445
+ $rootScope . $digest ( ) ;
5446
+
5447
+ expect ( $rootScope . name ) . toEqual ( [ 'inner' ] ) ;
5448
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5449
+
5450
+ expect ( log ) . toEqual ( [
5451
+ 'constructor' ,
5452
+ [ '$onChanges' , jasmine . objectContaining ( { currentValue : [ 'outer' ] } ) ] ,
5453
+ '$onInit'
5454
+ ] ) ;
5455
+ } ) ;
5456
+ } ) ;
5457
+
5458
+ it ( 'should update isolate again after $onInit if outer object reference changes even if equal' , function ( ) {
5459
+ module ( 'owComponentTest' ) ;
5460
+ inject ( function ( ) {
5461
+ $rootScope . name = [ 'outer' ] ;
5462
+ compile ( '<ow-component input="name"></ow-component>' ) ;
5463
+
5464
+ expect ( $rootScope . name ) . toEqual ( [ 'outer' ] ) ;
5465
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5466
+
5467
+ $rootScope . name = [ 'outer' ] ;
5468
+ $rootScope . $digest ( ) ;
5469
+
5470
+ expect ( $rootScope . name ) . toEqual ( [ 'outer' ] ) ;
5471
+ expect ( component . input ) . toEqual ( [ 'outer' ] ) ;
5472
+
5473
+ expect ( log ) . toEqual ( [
5474
+ 'constructor' ,
5475
+ [ '$onChanges' , jasmine . objectContaining ( { currentValue : [ 'outer' ] } ) ] ,
5476
+ '$onInit' ,
5477
+ [ '$onChanges' , jasmine . objectContaining ( { previousValue : [ 'outer' ] , currentValue : [ 'outer' ] } ) ]
5478
+ ] ) ;
5479
+ } ) ;
5480
+ } ) ;
5481
+
5435
5482
it ( 'should not update isolate again after $onInit if outer is a literal' , function ( ) {
5436
5483
module ( 'owComponentTest' ) ;
5437
5484
inject ( function ( ) {
0 commit comments