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 @@ -3477,18 +3477,21 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
34773477 if ( optional && ! attrs [ attrName ] ) break ;
34783478
34793479 parentGet = $parse ( attrs [ attrName ] ) ;
3480+ var deepWatch = parentGet . literal ;
34803481
34813482 var initialValue = destination [ scopeName ] = parentGet ( scope ) ;
34823483 initialChanges [ scopeName ] = new SimpleChange ( _UNINITIALIZED_VALUE , destination [ scopeName ] ) ;
34833484
34843485 removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newValue , oldValue ) {
34853486 if ( oldValue === newValue ) {
3486- if ( oldValue === initialValue ) return ;
3487+ if ( oldValue === initialValue || ( deepWatch && equals ( oldValue , initialValue ) ) ) {
3488+ return ;
3489+ }
34873490 oldValue = initialValue ;
34883491 }
34893492 recordChanges ( scopeName , newValue , oldValue ) ;
34903493 destination [ scopeName ] = newValue ;
3491- } , parentGet . literal ) ;
3494+ } , deepWatch ) ;
34923495
34933496 removeWatchCollection . push ( removeWatch ) ;
34943497 break ;
Original file line number Diff line number Diff line change @@ -5476,7 +5476,7 @@ describe('$compile', function() {
54765476 expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
54775477 expect ( component . input ) . toEqual ( '$onInit' ) ;
54785478
5479- $rootScope . $apply ( ) ;
5479+ $rootScope . $digest ( ) ;
54805480
54815481 expect ( $rootScope . name ) . toEqual ( 'outer' ) ;
54825482 expect ( component . input ) . toEqual ( '$onInit' ) ;
@@ -5489,6 +5489,37 @@ describe('$compile', function() {
54895489 } ) ;
54905490 } ) ;
54915491
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+
54925523 it ( 'should update isolate again after $onInit if outer has changed (before initial watchAction call)' , function ( ) {
54935524 module ( 'owComponentTest' ) ;
54945525 inject ( function ( ) {
You can’t perform that action at this time.
0 commit comments