I've come to dislike switch
because it's become so noisy and verbose over plain if/else, even if I have to repeat the condition multiple times.
This:
if (event.key === 'Tab') {
showExtras = true;
} else if (event.key === 'ArrowDown') {
focusNext('.ext-name, [type="search"]');
} else if (event.key === 'ArrowUp') {
focusPrevious('.ext-name, [type="search"]');
} else {
return;
}
Turns into:
switch (event.key) {
case 'Tab': {
showExtras = true;
break;
}
case 'ArrowDown': {
focusNext('.ext-name, [type="search"]');
break;
}
case 'ArrowUp': {
focusPrevious('.ext-name, [type="search"]');
break;
}
default: {
return;
}
}
The latter is arguably more readable/airy, but so is this:
switch (event.key) {
case 'Tab':
showExtras = true;
break;
case 'ArrowDown':
focusNext('.ext-name, [type="search"]');
break;
case 'ArrowUp':
focusPrevious('.ext-name, [type="search"]');
break;
default:
return;
}
I don’t think that the braces add anything here.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too