Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form is passed as the final argument to event handlers #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Forms.methods({
form.doc(propertyName, propertyValue);
});
var updatedDoc = Tracker.nonreactive(function () { return form.doc(); });
return ['documentChange', updatedDoc, changes];
return ['documentChange', updatedDoc, changes, form];
})
, invalidate: makeEventTrigger(function (propertyName, errors) {
var form = this;
Expand All @@ -321,12 +321,12 @@ Forms.methods({
form.errors(errors);
updatedDoc = Tracker.nonreactive(function () { return form.doc(); });
updatedErrors = Tracker.nonreactive(function () { return form.errors(); });
return ['documentInvalid', updatedDoc, updatedErrors];
return ['documentInvalid', updatedDoc, updatedErrors, form];
} else {
form.errors(propertyName, errors);
updatedDoc = Tracker.nonreactive(function () { return form.doc(); });
updatedErrors = Tracker.nonreactive(function () { return form.errors(propertyName); });
return ['propertyInvalid', updatedDoc, updatedErrors];
return ['propertyInvalid', updatedDoc, updatedErrors, form];
}
})
, validate: makeEventTrigger(function (propertyName) {
Expand Down Expand Up @@ -365,14 +365,14 @@ Forms.methods({
if (errors.length) {
updatedDoc = Tracker.nonreactive(function () { return form.doc(); });
updatedErrors = Tracker.nonreactive(function () { return form.errors(); });
return ['documentInvalid', updatedDoc, updatedErrors];
return ['documentInvalid', updatedDoc, updatedErrors, form];
}
} else {
form.errors(propertyName, errors);
if (errors.length) {
updatedDoc = Tracker.nonreactive(function () { return form.doc(); });
updatedErrors = Tracker.nonreactive(function () { return form.errors(propertyName); });
return ['propertyInvalid', updatedDoc, updatedErrors];
return ['propertyInvalid', updatedDoc, updatedErrors, form];
}
}
return null;
Expand All @@ -383,9 +383,9 @@ Forms.methods({
var updatedDoc = Tracker.nonreactive(function () { return form.doc(); });
var updatedErrors = Tracker.nonreactive(function () { return form.errors(); });
if (updatedErrors.length) {
return ['documentInvalid', updatedDoc, updatedErrors];
return ['documentInvalid', updatedDoc, updatedErrors, form];
} else {
return ['documentSubmit', updatedDoc];
return ['documentSubmit', updatedDoc, form];
}
})
});
Expand Down