Skip to content

Commit

Permalink
fix: passing down set options in columns/rows
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Oct 22, 2018
1 parent ec237fa commit 99e0383
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,18 @@ const getKeyPath = (parentKey, option) => {
(parentKey && option.name ? '.' : '') + (option.name || '');
};

const addOptions = (value, save, option, key) => {
if (value == null || typeof value !== 'object') {
value = {};
const addOptions = (values, save, option, key) => {
if (values == null || typeof values !== 'object') {
values = {};
}
return h('.suboptions', option.options.map((option) => {
const optionKey = getKeyPath(key, option);
return chrome.options.addOption(optionKey, value[option.name],
const isLayout = option.type === 'column' || option.type === 'row';
const value = isLayout ? values : values[option.name];
return chrome.options.addOption(optionKey, value,
(newValue) => {
if (option.name) { value[option.name] = newValue; }
save(value);
if (option.name) { values[option.name] = newValue; }
save(values);
}, option);
}));
};
Expand Down

0 comments on commit 99e0383

Please sign in to comment.