Skip to content

Commit

Permalink
Improve speed of getInputs
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Sep 3, 2017
1 parent 33fd31b commit 028a280
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/VForm/VForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ export default {
getInputs () {
const results = []

const filter = el => typeof el.errorBucket !== 'undefined'

const search = (children) => {
const search = (children, depth = 0) => {
for (const child of children) {
filter(child) ? results.push(child) : search(child.$children)
if (child.errorBucket !== undefined) {
results.push(child)
} else {
search(child.$children, depth + 1)
}
}
if (depth === 0) return results
}

search(this.$children)
return search(this.$children)

return results
},
Expand Down

0 comments on commit 028a280

Please sign in to comment.