summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-10-25 08:42:10 +0000
committerFatih Acet <acetfatih@gmail.com>2016-10-25 08:42:10 +0000
commit2f470a626238be535c59efa56affb170114651ac (patch)
tree61685b32e4cd96865e11a76003d5001ee2f4f9ea /app/assets
parent99eb15437d9cd81bfa61c090914084a27d9d8d8f (diff)
parent06564f9e049417087fa53cf8ec15c22ec65724d5 (diff)
downloadgitlab-ce-2f470a626238be535c59efa56affb170114651ac.tar.gz
Merge branch 'scope-input-errors' into 'master'
Stop injecting field errors where they won't be used. ## What does this MR do? Filters the form elements which gl_field_errors validates, excluding input types button, submit and checkbox. ## Why was this MR needed? This won't make a difference in UX, but I just noticed that we are currently validating and injecting errors into the DOM for all non-hidden inputs. Doing so is unnecessary, and could introduce performance problems on forms with larger numbers of inputs. ## Does this MR meet the acceptance criteria? - [x] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if it does - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !6929
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/gl_field_errors.js.es67
1 files changed, 5 insertions, 2 deletions
diff --git a/app/assets/javascripts/gl_field_errors.js.es6 b/app/assets/javascripts/gl_field_errors.js.es6
index 8657e7b4abf..8e8f9f29ab3 100644
--- a/app/assets/javascripts/gl_field_errors.js.es6
+++ b/app/assets/javascripts/gl_field_errors.js.es6
@@ -137,8 +137,11 @@
}
initValidators () {
- // select all non-hidden inputs in form
- this.state.inputs = this.form.find(':input:not([type=hidden])').toArray()
+ // register selectors here as needed
+ const validateSelectors = [':text', ':password', '[type=email]']
+ .map((selector) => `input${selector}`).join(',');
+
+ this.state.inputs = this.form.find(validateSelectors).toArray()
.filter((input) => !input.classList.contains(customValidationFlag))
.map((input) => new GlFieldError({ input, formErrors: this }));