@@ -3197,10 +3197,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3197
3197
destination [ scopeName ] = parentGet ( scope ) ;
3198
3198
initialChanges [ scopeName ] = new SimpleChange ( _UNINITIALIZED_VALUE , destination [ scopeName ] ) ;
3199
3199
3200
- removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newParentValue ) {
3201
- var oldValue = destination [ scopeName ] ;
3202
- recordChanges ( scopeName , newParentValue , oldValue ) ;
3203
- destination [ scopeName ] = newParentValue ;
3200
+ removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newValue , oldValue ) {
3201
+ if ( newValue === oldValue ) {
3202
+ // If the new and old values are identical then this is the first time the watch has been triggered
3203
+ // So instead we use the current value on the destination as the old value
3204
+ oldValue = destination [ scopeName ] ;
3205
+ }
3206
+ recordChanges ( scopeName , newValue , oldValue ) ;
3207
+ destination [ scopeName ] = newValue ;
3204
3208
} , parentGet . literal ) ;
3205
3209
3206
3210
removeWatchCollection . push ( removeWatch ) ;
@@ -3233,7 +3237,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3233
3237
onChangesQueue . push ( triggerOnChangesHook ) ;
3234
3238
}
3235
3239
// If the has been a change on this property already then we need to reuse the previous value
3236
- if ( changes [ key ] ) {
3240
+ if ( isDefined ( changes [ key ] ) ) {
3237
3241
previousValue = changes [ key ] . previousValue ;
3238
3242
}
3239
3243
// Store this change
0 commit comments