From a901ca29c1a2d7e05e5d8ce8125cf9b9ecbe7d86 Mon Sep 17 00:00:00 2001 From: eight Date: Mon, 9 Oct 2017 00:59:10 +0800 Subject: [PATCH] Add: allow array in var select --- js/usercss.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/js/usercss.js b/js/usercss.js index 80315cdd..189d0d17 100644 --- a/js/usercss.js +++ b/js/usercss.js @@ -198,10 +198,17 @@ var usercss = (function () { result.default = match[1]; } else if (state.type === 'select' || (state.type === 'image' && state.key === 'var')) { parseJSON(state); - result.options = Object.keys(state.value).map(k => ({ - label: k, - value: state.value[k] - })); + if (Array.isArray(state.value)) { + result.options = state.value.map(text => ({ + label: text, + value: text + })); + } else { + result.options = Object.keys(state.value).map(k => ({ + label: k, + value: state.value[k] + })); + } result.default = result.options[0].value; } else if (state.type === 'dropdown' || state.type === 'image') { if (state.text[state.re.lastIndex] !== '{') {