Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit da1f426

Browse files
committed
Fix a small issue introduced by last commit
1 parent df85bb0 commit da1f426

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.11",
3+
"version": "1.5.12",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": [

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Angular-Validation change logs
22

3+
1.5.12 (2016-12-15) Fix a small issue introduced by last commit (Angular Form overwritten with simple object).
34
1.5.11 (2016-12-15) Fix checkFormValidity with formName argument, issues #135 #139 #140 #141
45
1.5.10 (2016-12-13) Fix UI Router issue by adding a UI Router watch on $stateChangeStart, issue #137
56
1.5.9 (2016-10-14) Updated main entry at package.json to work with WebPack, issue #128

dist/angular-validation.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.11",
3+
"version": "1.5.12",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": "dist/angular-validation.min",
77
"dependencies": {},
88
"devDependencies": {
99
"del": "^1.2.1",
10-
"fs": "0.0.1-security",
10+
"fs": "0.0.0",
1111
"gulp": "^3.9.0",
1212
"gulp-angular-protractor": "^0.2.0",
1313
"gulp-bump": "^0.3.1",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.5.11`
2+
`Version: 1.5.12`
33
### Forms Validation with Angular made easy!
44
##### (Concept comes from the amazing Laravel)
55

src/validation-common.js

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,30 @@ angular
790790
return -1;
791791
}
792792

793+
/** From a javascript plain form object, find its equivalent Angular object
794+
* @param object formObj
795+
* @param object self
796+
* @return object angularParentForm or null
797+
*/
798+
function findAngularParentFormInScope(formObj, self) {
799+
var formName = (!!formObj) ? formObj.getAttribute("name") : null;
800+
801+
if (!!formObj && !!formName) {
802+
parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0)
803+
? objectFindById(self.scope, formName, '.')
804+
: self.scope[formName];
805+
806+
if(!!parentForm) {
807+
if (typeof parentForm.$name === "undefined") {
808+
parentForm.$name = formName; // make sure it has a $name, since we use that variable later on
809+
}
810+
return parentForm;
811+
}
812+
}
813+
814+
return null;
815+
}
816+
793817
/** Get the element's parent Angular form (if found)
794818
* @param string: element input name
795819
* @param object self
@@ -811,28 +835,22 @@ angular
811835

812836
for (var i = 0; i < forms.length; i++) {
813837
var form = forms[i].form;
814-
var formName = (!!form) ? form.getAttribute("name") : null;
815-
816-
if (!!form && !!formName) {
817-
parentForm = (!!_globalOptions && !!_globalOptions.controllerAs && formName.indexOf('.') >= 0)
818-
? objectFindById(self.scope, formName, '.')
819-
: self.scope[formName];
820-
821-
if(!!parentForm) {
822-
if (typeof parentForm.$name === "undefined") {
823-
parentForm.$name = formName; // make sure it has a $name, since we use that variable later on
824-
}
825-
return parentForm;
826-
}
838+
var angularParentForm = findAngularParentFormInScope(form, self);
839+
if(!!angularParentForm) {
840+
return angularParentForm;
827841
}
828842
}
829843

830-
// if we haven't found a form yet, then we have a special angular element, let's try with .closest (this might not work with older browser)
844+
// if we haven't found a form yet, then we have a special angular element, let's try with .closest
831845
if(!form) {
832-
var element = document.querySelector('[name="'+elmName+'"]');
833-
if(element) {
834-
form = element.closest("form");
846+
var element = document.querySelector('[name="'+elmName+'"]');
847+
if(!!element) {
848+
var form = element.closest("form");
849+
var angularParentForm = findAngularParentFormInScope(form, self);
850+
if(!!angularParentForm) {
851+
return angularParentForm;
835852
}
853+
}
836854
}
837855

838856
// falling here with a form name but without a form object found in the scope is often due to isolate scope

0 commit comments

Comments
 (0)