fac-13 / jeth

Find jobs near you :computer:
https://jeth.herokuapp.com/
1 stars 2 forks source link

Relying less on non-local scopes #42

Open eliasmalik opened 6 years ago

eliasmalik commented 6 years ago

If, in the distant future, you were going to try to test some of your client-side javascript, it would make your life easier if your functions relied less on variables in non-local scopes. For example:

https://github.com/fac-13/jeth/blob/55aa475205ea69a649432a9c9cfd0b7e1854d083/public/dom.js#L29-L41

You could modify the definition of buildURL to accept a DOM node from which it extracts the query term:

Similarly, this "while firstChild" pattern appears a few times: https://github.com/fac-13/jeth/blob/55aa475205ea69a649432a9c9cfd0b7e1854d083/public/dom.js#L43-L47

Accepting the root DOM node as an argument would make this function more general and allow you to re-use it the other places where this pattern is used.