Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ca5fcc6

Browse files
committed
refactor(ngModel): clarify the arguments of $setValidity
1 parent 2408f2d commit ca5fcc6

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/ng/directive/form.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,23 @@ function FormController(element, attrs, $scope, $animate, $interpolate) {
183183
addSetValidityMethod({
184184
ctrl: this,
185185
$element: element,
186-
set: function(object, property, control) {
186+
set: function(object, property, controller) {
187187
var list = object[property];
188188
if (!list) {
189-
object[property] = [control];
189+
object[property] = [controller];
190190
} else {
191-
var index = list.indexOf(control);
191+
var index = list.indexOf(controller);
192192
if (index === -1) {
193-
list.push(control);
193+
list.push(controller);
194194
}
195195
}
196196
},
197-
unset: function(object, property, control) {
197+
unset: function(object, property, controller) {
198198
var list = object[property];
199199
if (!list) {
200200
return;
201201
}
202-
arrayRemove(list, control);
202+
arrayRemove(list, controller);
203203
if (list.length === 0) {
204204
delete object[property];
205205
}

src/ng/directive/ngModel.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -1247,22 +1247,22 @@ function addSetValidityMethod(context) {
12471247

12481248
ctrl.$setValidity = setValidity;
12491249

1250-
function setValidity(validationErrorKey, state, options) {
1250+
function setValidity(validationErrorKey, state, controller) {
12511251
if (state === undefined) {
1252-
createAndSet('$pending', validationErrorKey, options);
1252+
createAndSet('$pending', validationErrorKey, controller);
12531253
} else {
1254-
unsetAndCleanup('$pending', validationErrorKey, options);
1254+
unsetAndCleanup('$pending', validationErrorKey, controller);
12551255
}
12561256
if (!isBoolean(state)) {
1257-
unset(ctrl.$error, validationErrorKey, options);
1258-
unset(ctrl.$$success, validationErrorKey, options);
1257+
unset(ctrl.$error, validationErrorKey, controller);
1258+
unset(ctrl.$$success, validationErrorKey, controller);
12591259
} else {
12601260
if (state) {
1261-
unset(ctrl.$error, validationErrorKey, options);
1262-
set(ctrl.$$success, validationErrorKey, options);
1261+
unset(ctrl.$error, validationErrorKey, controller);
1262+
set(ctrl.$$success, validationErrorKey, controller);
12631263
} else {
1264-
set(ctrl.$error, validationErrorKey, options);
1265-
unset(ctrl.$$success, validationErrorKey, options);
1264+
set(ctrl.$error, validationErrorKey, controller);
1265+
unset(ctrl.$$success, validationErrorKey, controller);
12661266
}
12671267
}
12681268
if (ctrl.$pending) {
@@ -1290,20 +1290,21 @@ function addSetValidityMethod(context) {
12901290
} else {
12911291
combinedState = null;
12921292
}
1293+
12931294
toggleValidationCss(validationErrorKey, combinedState);
12941295
parentForm.$setValidity(validationErrorKey, combinedState, ctrl);
12951296
}
12961297

1297-
function createAndSet(name, value, options) {
1298+
function createAndSet(name, value, controller) {
12981299
if (!ctrl[name]) {
12991300
ctrl[name] = {};
13001301
}
1301-
set(ctrl[name], value, options);
1302+
set(ctrl[name], value, controller);
13021303
}
13031304

1304-
function unsetAndCleanup(name, value, options) {
1305+
function unsetAndCleanup(name, value, controller) {
13051306
if (ctrl[name]) {
1306-
unset(ctrl[name], value, options);
1307+
unset(ctrl[name], value, controller);
13071308
}
13081309
if (isObjectEmpty(ctrl[name])) {
13091310
ctrl[name] = undefined;

0 commit comments

Comments
 (0)