/*
 * This function converts Storybook's object
 * argument type to a JSON string to make it compatible
 * with DOM attributes.
 */
export const stringifyObjects = args => {
  const keys = Object.keys(args);
  const output = {};
  keys.forEach(key => {
    const val = args[key];
    if (typeof val === 'object' && !val.length) {
      const stringified = JSON.stringify(val);
      output[key] = stringified;
    }
    else {
      output[key] = val;
    }
  });
  return output;
};
