Remove va.range & add min/max/step to va directly

This commit is contained in:
Rob Garrison 2018-09-16 18:22:50 -05:00
parent 568fc336e7
commit 1881552348

View File

@ -232,10 +232,13 @@ var usercss = (() => {
state.errorPrefix = ''; state.errorPrefix = '';
// [default, start, end, step, units] (start, end, step & units are optional) // [default, start, end, step, units] (start, end, step & units are optional)
if (Array.isArray(state.value) && state.value.length) { if (Array.isArray(state.value) && state.value.length) {
result.default = state.value.shift(); // label may be placed anywhere
// label may be placed anywhere after default value
result.units = (state.value.find(i => typeof i === 'string') || '').replace(/[\d.+-]/g, ''); result.units = (state.value.find(i => typeof i === 'string') || '').replace(/[\d.+-]/g, '');
result.range = state.value.filter(i => typeof i === 'number'); const range = state.value.filter(i => typeof i === 'number');
result.default = range[0];
result.min = range[1];
result.max = range[2];
result.step = range[3];
} }
break; break;
} }
@ -618,10 +621,7 @@ var usercss = (() => {
throw new Error(chrome.i18n.getMessage('styleMetaErrorCheckbox')); throw new Error(chrome.i18n.getMessage('styleMetaErrorCheckbox'));
} else if (va.type === 'color') { } else if (va.type === 'color') {
va[value] = colorConverter.format(colorConverter.parse(va[value]), 'rgb'); va[value] = colorConverter.format(colorConverter.parse(va[value]), 'rgb');
} else if ( } else if ((va.type === 'number' || va.type === 'range') && typeof va[value] !== 'number') {
(va.type === 'number' || va.type === 'range') &&
(typeof va[value] !== 'number' || !Array.isArray(va.range))
) {
throw new Error(chrome.i18n.getMessage('styleMetaErrorRangeOrNumber', va.type)); throw new Error(chrome.i18n.getMessage('styleMetaErrorRangeOrNumber', va.type));
} }
} }