@@ -3210,10 +3210,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3210
3210
destination [ scopeName ] = parentGet ( scope ) ;
3211
3211
initialChanges [ scopeName ] = new SimpleChange ( _UNINITIALIZED_VALUE , destination [ scopeName ] ) ;
3212
3212
3213
- removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newParentValue ) {
3214
- var oldValue = destination [ scopeName ] ;
3215
- recordChanges ( scopeName , newParentValue , oldValue ) ;
3216
- destination [ scopeName ] = newParentValue ;
3213
+ removeWatch = scope . $watch ( parentGet , function parentValueWatchAction ( newValue , oldValue ) {
3214
+ if ( newValue === oldValue ) {
3215
+ // If the new and old values are identical then this is the first time the watch has been triggered
3216
+ // So instead we use the current value on the destination as the old value
3217
+ oldValue = destination [ scopeName ] ;
3218
+ }
3219
+ recordChanges ( scopeName , newValue , oldValue ) ;
3220
+ destination [ scopeName ] = newValue ;
3217
3221
} , parentGet . literal ) ;
3218
3222
3219
3223
removeWatchCollection . push ( removeWatch ) ;
@@ -3246,7 +3250,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
3246
3250
onChangesQueue . push ( triggerOnChangesHook ) ;
3247
3251
}
3248
3252
// If the has been a change on this property already then we need to reuse the previous value
3249
- if ( changes [ key ] ) {
3253
+ if ( isDefined ( changes [ key ] ) ) {
3250
3254
previousValue = changes [ key ] . previousValue ;
3251
3255
}
3252
3256
// Store this change
0 commit comments