Skip to content

Commit 8331491

Browse files
committed
refactor(forms): Rename read() -> setViewValue()
1 parent e0cc84a commit 8331491

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/directive/input.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ function textInputType(scope, element, attr, ctrl) {
374374

375375
if (ctrl.viewValue !== value) {
376376
scope.$apply(function() {
377-
ctrl.read(value);
377+
ctrl.setViewValue(value);
378378
});
379379
} else if (touched) {
380380
scope.$apply();
@@ -559,7 +559,7 @@ function radioInputType(scope, element, attr, ctrl) {
559559
if (element[0].checked) {
560560
scope.$apply(function() {
561561
ctrl.touch();
562-
ctrl.read(attr.value);
562+
ctrl.setViewValue(attr.value);
563563
});
564564
};
565565
});
@@ -580,7 +580,7 @@ function checkboxInputType(scope, element, attr, ctrl) {
580580
element.bind('click', function() {
581581
scope.$apply(function() {
582582
ctrl.touch();
583-
ctrl.read(element[0].checked);
583+
ctrl.setViewValue(element[0].checked);
584584
});
585585
});
586586

@@ -830,7 +830,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', 'ngModel',
830830

831831
/**
832832
* @ngdoc function
833-
* @name angular.module.ng.$compileProvider.directive.ng-model.NgModelController#read
833+
* @name angular.module.ng.$compileProvider.directive.ng-model.NgModelController#setViewValue
834834
* @methodOf angular.module.ng.$compileProvider.directive.ng-model.NgModelController
835835
*
836836
* @description
@@ -845,7 +845,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', 'ngModel',
845845
*
846846
* @param {string} value Value from the view
847847
*/
848-
this.read = function(value) {
848+
this.setViewValue = function(value) {
849849
this.viewValue = value;
850850

851851
forEach(this.parsers, function(fn) {
@@ -1042,7 +1042,7 @@ var ngModelInstantDirective = ['$browser', function($browser) {
10421042

10431043
if (ctrl.viewValue !== value) {
10441044
scope.$apply(function() {
1045-
ctrl.read(value);
1045+
ctrl.setViewValue(value);
10461046
});
10471047
} else if (touched) {
10481048
scope.$apply();

src/directive/select.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
168168
selectElement.bind('change', function() {
169169
scope.$apply(function() {
170170
ctrl.touch();
171-
ctrl.read(selectElement.val());
171+
ctrl.setViewValue(selectElement.val());
172172
});
173173
});
174174
}
@@ -190,7 +190,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
190190
}
191191
});
192192
ctrl.touch();
193-
ctrl.read(array);
193+
ctrl.setViewValue(array);
194194
});
195195
});
196196
}
@@ -270,7 +270,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
270270
ctrl.touch();
271271

272272
if (ctrl.viewValue !== value) {
273-
ctrl.read(value);
273+
ctrl.setViewValue(value);
274274
}
275275
});
276276
});

test/directive/inputSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('NgModelController', function() {
113113
describe('view -> model', function() {
114114

115115
it('should set the value to $viewValue', function() {
116-
ctrl.read('some-val');
116+
ctrl.setViewValue('some-val');
117117
expect(ctrl.viewValue).toBe('some-val');
118118
});
119119

@@ -131,7 +131,7 @@ describe('NgModelController', function() {
131131
return value + '-b';
132132
});
133133

134-
ctrl.read('init');
134+
ctrl.setViewValue('init');
135135
expect(log).toEqual(['init', 'init-a']);
136136
expect(ctrl.modelValue).toBe('init-a-b');
137137
});
@@ -141,13 +141,13 @@ describe('NgModelController', function() {
141141
var spy = jasmine.createSpy('$viewChange');
142142
scope.$on('$viewChange', spy);
143143

144-
ctrl.read('val');
144+
ctrl.setViewValue('val');
145145
expect(spy).toHaveBeenCalledOnce();
146146
spy.reset();
147147

148148
// invalid
149149
ctrl.parsers.push(function() {return undefined;});
150-
ctrl.read('val');
150+
ctrl.setViewValue('val');
151151
expect(spy).not.toHaveBeenCalled();
152152
});
153153
});

0 commit comments

Comments
 (0)