All files / js/lib configure.js

100% Statements 7/7
100% Branches 4/4
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  120x 120x         227x       120x      
export default function configure(element, userOptions, defaultOptions) {
  return Object.keys(defaultOptions).reduce((options, key) => {
    const attrValue = element.getAttribute(`data-${key.toLowerCase()}`);
 
    // eslint-disable-next-line no-param-reassign
    if (attrValue !== null) options[key] = attrValue;
    // eslint-disable-next-line no-param-reassign
    else if (key in userOptions) options[key] = userOptions[key];
    // eslint-disable-next-line no-param-reassign
    else options[key] = defaultOptions[key];
 
    return options;
  }, {});
}