This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
Expand file tree Collapse file tree 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) {
35063506 if ( optional && ! attrs [ attrName ] ) break ;
35073507
35083508 parentGet = $parse ( attrs [ attrName ] ) ;
3509+ var deepWatch = parentGet . literal ;
35093510
35103511 var initialValue = destination [ scopeName ] = parentGet ( scope ) ;
35113512 initialChanges [ scopeName ] = new SimpleChange ( _UNINITIALIZED_VALUE , destination [ scopeName ] ) ;
35123513
35133514 removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newValue , oldValue ) {
35143515 if ( oldValue === newValue ) {
3515- if ( oldValue === initialValue ) return ;
3516+ if ( oldValue === initialValue || ( deepWatch && equals ( oldValue , initialValue ) ) ) {
3517+ return ;
3518+ }
35163519 oldValue = initialValue ;
35173520 }
35183521 recordChanges ( scopeName , newValue , oldValue ) ;
35193522 destination [ scopeName ] = newValue ;
3520- } , parentGet . literal ) ;
3523+ } , deepWatch ) ;
35213524
35223525 removeWatchCollection . push ( removeWatch ) ;
35233526 break ;
Original file line number Diff line number Diff line change @@ -5524,7 +5524,7 @@ describe('$compile', function() {
55245524 expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
55255525 expect ( component . input ) . toEqual ( '$onInit' ) ;
55265526
5527- $rootScope . $apply ( ) ;
5527+ $rootScope . $digest ( ) ;
55285528
55295529 expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
55305530 expect ( component . input ) . toEqual ( '$onInit' ) ;
@@ -5537,6 +5537,37 @@ describe('$compile', function() {
55375537 } ) ;
55385538 } ) ;
55395539
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+
55405571 it ( 'should update isolate again after $onInit if outer has changed (before initial watchAction call)' , function ( ) {
55415572 module ( 'owComponentTest' ) ;
55425573 inject ( function ( ) {
You can’t perform that action at this time.
0 commit comments