There's a few things that can be reviewed:
Your indentation and spacing are incorrect, use JSFiddle's TidyUp function to clean it up.
All of the e.keyCode ==
matches shouldn't be matched to magic numbers, but moved to a kind of enum or something similar:
var KEYS = {
Enter: 13,
DownArrow: 40,
UpArrow: 38
};
// ...
if (e.keyCode == KEYS.Enter){
##suggList
:
suggList
:
Don't sacrifice readability for a few characters: suggestedList
is more than fine.
##console.error
:
console.error
:
Instead of console.error
, use throw
instead: console.error('No sourceList provided for customAutoComplete')
into: throw 'ACError: No sourceList provided for customAutoComplete'
There's a few things that can be reviewed:
Your indentation and spacing are incorrect, use JSFiddle's TidyUp function to clean it up.
All of the e.keyCode ==
matches shouldn't be matched to magic numbers, but moved to a kind of enum or something similar:
var KEYS = {
Enter: 13,
DownArrow: 40,
UpArrow: 38
};
// ...
if (e.keyCode == KEYS.Enter){
##suggList
:
Don't sacrifice readability for a few characters: suggestedList
is more than fine.
##console.error
:
Instead of console.error
, use throw
instead: console.error('No sourceList provided for customAutoComplete')
into: throw 'ACError: No sourceList provided for customAutoComplete'
There's a few things that can be reviewed:
Your indentation and spacing are incorrect, use JSFiddle's TidyUp function to clean it up.
All of the e.keyCode ==
matches shouldn't be matched to magic numbers, but moved to a kind of enum or something similar:
var KEYS = {
Enter: 13,
DownArrow: 40,
UpArrow: 38
};
// ...
if (e.keyCode == KEYS.Enter){
suggList
:
Don't sacrifice readability for a few characters: suggestedList
is more than fine.
console.error
:
Instead of console.error
, use throw
instead: console.error('No sourceList provided for customAutoComplete')
into: throw 'ACError: No sourceList provided for customAutoComplete'
There's a few things that can be reviewed:
Your indentation and spacing are incorrect, use JSFiddle's TidyUp function to clean it up.
All of the e.keyCode ==
matches shouldn't be matched to magic numbers, but moved to a kind of enum or something similar:
var KEYS = {
Enter: 13,
DownArrow: 40,
UpArrow: 38
};
// ...
if (e.keyCode == KEYS.Enter){
##suggList
:
Don't sacrifice readability for a few characters: suggestedList
is more than fine.
##console.error
:
Instead of console.error
, use throw
instead: console.error('No sourceList provided for customAutoComplete')
into: throw 'ACError: No sourceList provided for customAutoComplete'