Skip to content

Commit 5346772

Browse files
committed
perf(ngModel): move model -> view pipeline to watch action
1 parent 20590c0 commit 5346772

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ng/directive/ngModel.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -892,13 +892,16 @@ function setupModelWatcher(ctrl) {
892892
// 4. view should be changed back to 'a'
893893
ctrl.$$scope.$watch(function ngModelWatch(scope) {
894894
var modelValue = ctrl.$$ngModelGet(scope);
895+
return modelValue;
896+
}, ngModelWatchAction);
895897

898+
function ngModelWatchAction(modelValue) {
896899
// if scope model value and ngModel value are out of sync
897900
// TODO(perf): why not move this to the action fn?
898901
if (modelValue !== ctrl.$modelValue &&
899-
// checks for NaN is needed to allow setting the model to NaN when there's an asyncValidator
900-
// eslint-disable-next-line no-self-compare
901-
(ctrl.$modelValue === ctrl.$modelValue || modelValue === modelValue)
902+
// checks for NaN is needed to allow setting the model to NaN when there's an asyncValidator
903+
// eslint-disable-next-line no-self-compare
904+
(ctrl.$modelValue === ctrl.$modelValue || modelValue === modelValue)
902905
) {
903906
ctrl.$modelValue = ctrl.$$rawModelValue = modelValue;
904907
ctrl.$$parserValid = undefined;
@@ -921,7 +924,8 @@ function setupModelWatcher(ctrl) {
921924
}
922925

923926
return modelValue;
924-
});
927+
}
928+
925929
}
926930

927931
/**

0 commit comments

Comments
 (0)