史上最差的 Case 转化实现
let transformer = document.createElement('span')

function camel2kebab(name) {
  const dataset = transformer.dataset
  dataset[name] = '1'
  const key = transformer.attributes[0].name
  delete dataset[name]
  return key.substring(5)
}

function kebab2camel(name) {
  transformer.setAttribute(`data-${name}`, '1')
  const dataset = transformer.dataset
  const key = Object.keys(dataset)[0]
  delete dataset[key]
  return key
}

Powered by Sairin