-
Notifications
You must be signed in to change notification settings - Fork 4
Possible improvements in WordPress core JavaScript
Anton Timmermans edited this page Jun 16, 2018
·
6 revisions
This is a list of code smells that could be improved to make the code more readable.
- Callback hell. Solution: Refactor functions into named functions.
-
data.match(/tag_ID=(\d+)/)[1]should be extracted to a variable calledterm_id.
-
intervalis currently both a getter and a setter. It would be better to split this into a proper getter and setter.
- Keycodes are magic numbers and should be abstracted to
ENTERvariables. (Maybe find those in all of WordPress so keycodes become easier in general.) - Variable names (
while ( t && t != aB && t != d ) {).
- Node types are magic numbers and should be abstracted to a
NODE_TYPE_TEXT_NODEvariable.