Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(forms): change valid_submit and invalid_submit to camelcase
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All form code that uses control.valid_submit and control.invalid_submit
will throw an error. Instead use control.validSubmit and control.invalidSubmit to check
the submission validitity on a control.

Closes #793
  • Loading branch information
matsko authored and mhevery committed Mar 28, 2014
1 parent c5236ff commit e5baa50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions lib/directive/ng_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
static const NG_SUBMIT_INVALID = "ng-submit-invalid";

String _name;
bool _submit_valid;
bool _submitValid;

final NgControl _parentControl;
final NgAnimate _animate;
Expand Down Expand Up @@ -63,10 +63,10 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {

void onSubmit(bool valid) {
if (valid) {
_submit_valid = true;
_submitValid = true;
element..addClass(NG_SUBMIT_VALID)..removeClass(NG_SUBMIT_INVALID);
} else {
_submit_valid = false;
_submitValid = false;
element..addClass(NG_SUBMIT_INVALID)..removeClass(NG_SUBMIT_VALID);
}
_controls.forEach((control) {
Expand All @@ -79,17 +79,17 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
/**
* Whether or not the form has been submitted yet.
*/
bool get submitted => _submit_valid != null;
bool get submitted => _submitValid != null;

/**
* Whether or not the form was valid when last submitted.
*/
bool get valid_submit => _submit_valid == true;
bool get validSubmit => _submitValid == true;

/**
* Whether or not the form was invalid when last submitted.
*/
bool get invalid_submit => _submit_valid == false;
bool get invalidSubmit => _submitValid == false;

String get name => _name;
set name(value) {
Expand Down Expand Up @@ -297,7 +297,7 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
}

class NgNullControl implements NgControl {
var _name, _dirty, _valid, _submit_valid, _pristine, _element, _touched;
var _name, _dirty, _valid, _submitValid, _pristine, _element, _touched;
var _controls, _parentControl, _controlName, _animate, infoStates, errorStates;
var errors, _controlByName;
NgElement element;
Expand All @@ -313,8 +313,8 @@ class NgNullControl implements NgControl {
set name(name) {}

bool get submitted => false;
bool get valid_submit => true;
bool get invalid_submit => false;
bool get validSubmit => true;
bool get invalidSubmit => false;
bool get pristine => true;
bool get dirty => false;
bool get valid => true;
Expand Down
12 changes: 6 additions & 6 deletions test/directive/ng_form_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ void main() {
var formElement = form.element.node;

expect(form.submitted).toBe(false);
expect(form.valid_submit).toBe(false);
expect(form.invalid_submit).toBe(false);
expect(form.validSubmit).toBe(false);
expect(form.invalidSubmit).toBe(false);
expect(formElement.classes.contains('ng-submit-invalid')).toBe(false);
expect(formElement.classes.contains('ng-submit-valid')).toBe(false);

Expand All @@ -533,8 +533,8 @@ void main() {
scope.apply();

expect(form.submitted).toBe(true);
expect(form.valid_submit).toBe(false);
expect(form.invalid_submit).toBe(true);
expect(form.validSubmit).toBe(false);
expect(form.invalidSubmit).toBe(true);
expect(formElement.classes.contains('ng-submit-invalid')).toBe(true);
expect(formElement.classes.contains('ng-submit-valid')).toBe(false);

Expand All @@ -543,8 +543,8 @@ void main() {
scope.apply();

expect(form.submitted).toBe(true);
expect(form.valid_submit).toBe(true);
expect(form.invalid_submit).toBe(false);
expect(form.validSubmit).toBe(true);
expect(form.invalidSubmit).toBe(false);
expect(formElement.classes.contains('ng-submit-invalid')).toBe(false);
expect(formElement.classes.contains('ng-submit-valid')).toBe(true);
});
Expand Down

0 comments on commit e5baa50

Please sign in to comment.