This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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 @@ -3506,18 +3506,21 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3506
3506
if ( optional && ! attrs [ attrName ] ) break ;
3507
3507
3508
3508
parentGet = $parse ( attrs [ attrName ] ) ;
3509
+ var deepWatch = parentGet . literal ;
3509
3510
3510
3511
var initialValue = destination [ scopeName ] = parentGet ( scope ) ;
3511
3512
initialChanges [ scopeName ] = new SimpleChange ( _UNINITIALIZED_VALUE , destination [ scopeName ] ) ;
3512
3513
3513
3514
removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newValue , oldValue ) {
3514
3515
if ( oldValue === newValue ) {
3515
- if ( oldValue === initialValue ) return ;
3516
+ if ( oldValue === initialValue || ( deepWatch && equals ( oldValue , initialValue ) ) ) {
3517
+ return ;
3518
+ }
3516
3519
oldValue = initialValue ;
3517
3520
}
3518
3521
recordChanges ( scopeName , newValue , oldValue ) ;
3519
3522
destination [ scopeName ] = newValue ;
3520
- } , parentGet . literal ) ;
3523
+ } , deepWatch ) ;
3521
3524
3522
3525
removeWatchCollection . push ( removeWatch ) ;
3523
3526
break ;
Original file line number Diff line number Diff line change @@ -5524,7 +5524,7 @@ describe('$compile', function() {
5524
5524
expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
5525
5525
expect ( component . input ) . toEqual ( '$onInit' ) ;
5526
5526
5527
- $rootScope . $apply ( ) ;
5527
+ $rootScope . $digest ( ) ;
5528
5528
5529
5529
expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
5530
5530
expect ( component . input ) . toEqual ( '$onInit' ) ;
@@ -5537,6 +5537,37 @@ describe('$compile', function() {
5537
5537
} ) ;
5538
5538
} ) ;
5539
5539
5540
+ it ( 'should not update isolate again after $onInit if outer is a literal' , function ( ) {
5541
+ module ( 'owComponentTest' ) ;
5542
+ inject ( function ( ) {
5543
+ $rootScope . name = 'outer' ;
5544
+ compile ( '<ow-component input="[name]"></ow-component>' ) ;
5545
+
5546
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5547
+
5548
+ // No outer change
5549
+ $rootScope . $apply ( 'name = "outer"' ) ;
5550
+ expect ( component . input ) . toEqual ( '$onInit' ) ;
5551
+
5552
+ // Outer change
5553
+ $rootScope . $apply ( 'name = "re-outer"' ) ;
5554
+ expect ( component . input ) . toEqual ( [ 're-outer' ] ) ;
5555
+
5556
+ expect ( log ) . toEqual ( [
5557
+ 'constructor' ,
5558
+ [
5559
+ '$onChanges' ,
5560
+ jasmine . objectContaining ( { currentValue : [ 'outer' ] } )
5561
+ ] ,
5562
+ '$onInit' ,
5563
+ [
5564
+ '$onChanges' ,
5565
+ jasmine . objectContaining ( { previousValue : [ 'outer' ] , currentValue : [ 're-outer' ] } )
5566
+ ]
5567
+ ] ) ;
5568
+ } ) ;
5569
+ } ) ;
5570
+
5540
5571
it ( 'should update isolate again after $onInit if outer has changed (before initial watchAction call)' , function ( ) {
5541
5572
module ( 'owComponentTest' ) ;
5542
5573
inject ( function ( ) {
You can’t perform that action at this time.
0 commit comments