I have a switch based on an elements "type" that triggers different default settings.
Multiple "types" often share default settings like backgroundColor so we bunch them together in a multiple case setup. As we modify it's nice to be able to adjust each "type" as we go and often end up with a lot of duplication as then it's each type in it's own little box.
What I'd like to do is use a case where it is shared, and then again later declare it for its special properties.
Something like:
function setDefaults(base) {
switch (base.type) {
case 'rectangle':
case 'circle':
case 'areaMap':
case 'clock':
case 'news':
case 'weather':
case 'webview':
case 'camera':
base.properties.background = this._getRandColor();
case 'areaMap':
base.properties.height = '600px';
base.properties.width = '800px';
break;
}
return base;
}
I'm not sure if this will work or not...
case 'areaMap'is completely redundant .. all preceding cases fall through to that codeifblock, or conditional function call, or even avoidswitchstatement entirely. All dependent on your coding style