File tree 2 files changed +37
-3
lines changed
2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -3487,18 +3487,21 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3487
3487
if ( optional && ! attrs [ attrName ] ) break ;
3488
3488
3489
3489
parentGet = $parse ( attrs [ attrName ] ) ;
3490
+ var deepWatch = parentGet . literal ;
3490
3491
3491
3492
var initialValue = destination [ scopeName ] = parentGet ( scope ) ;
3492
3493
initialChanges [ scopeName ] = new SimpleChange ( _UNINITIALIZED_VALUE , destination [ scopeName ] ) ;
3493
3494
3494
3495
removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newValue , oldValue ) {
3495
3496
if ( oldValue === newValue ) {
3496
- if ( oldValue === initialValue ) return ;
3497
+ if ( oldValue === initialValue || ( deepWatch && equals ( oldValue , initialValue ) ) ) {
3498
+ return ;
3499
+ }
3497
3500
oldValue = initialValue ;
3498
3501
}
3499
3502
recordChanges ( scopeName , newValue , oldValue ) ;
3500
3503
destination [ scopeName ] = newValue ;
3501
- } , parentGet . literal ) ;
3504
+ } , deepWatch ) ;
3502
3505
3503
3506
removeWatchCollection . push ( removeWatch ) ;
3504
3507
break ;
Original file line number Diff line number Diff line change @@ -5476,7 +5476,7 @@ describe('$compile', function() {
5476
5476
expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
5477
5477
expect ( component . input ) . toEqual ( '$onInit' ) ;
5478
5478
5479
- $rootScope . $apply ( ) ;
5479
+ $rootScope . $digest ( ) ;
5480
5480
5481
5481
expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
5482
5482
expect ( component . input ) . toEqual ( '$onInit' ) ;
@@ -5489,6 +5489,37 @@ describe('$compile', function() {
5489
5489
} ) ;
5490
5490
} ) ;
5491
5491
5492
+ it ( 'should not update isolate again after $onInit if outer is a literal' , function ( ) {
5493
+ module ( 'owComponentTest' ) ;
5494
+ inject ( function ( ) {
5495
+ $rootScope . name = 'outer' ;
5496
+ compile ( '<ow-component input="[name]"></ow-component>' ) ;
5497
+
5498
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5499
+
5500
+ // No outer change
5501
+ $rootScope . $apply ( 'name = "outer"' ) ;
5502
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5503
+
5504
+ // Outer change
5505
+ $rootScope . $apply ( 'name = "re-outer"' ) ;
5506
+ expect ( component . input ) . toEqual ( [ 're-outer' ] ) ;
5507
+
5508
+ expect ( log ) . toEqual ( [
5509
+ 'constructor' ,
5510
+ [
5511
+ '$onChanges' ,
5512
+ jasmine . objectContaining ( { currentValue : [ 'outer' ] } )
5513
+ ] ,
5514
+ '$onInit' ,
5515
+ [
5516
+ '$onChanges' ,
5517
+ jasmine . objectContaining ( { previousValue : [ 'outer' ] , currentValue : [ 're-outer' ] } )
5518
+ ]
5519
+ ] ) ;
5520
+ } ) ;
5521
+ } ) ;
5522
+
5492
5523
it ( 'should update isolate again after $onInit if outer has changed (before initial watchAction call)' , function ( ) {
5493
5524
module ( 'owComponentTest' ) ;
5494
5525
inject ( function ( ) {
You can’t perform that action at this time.
0 commit comments