Becklyn / mojave

A library of commonly used JavaScript tools and helpers by Becklyn
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

createElement: Add support for setting data-attributes with `data` object #159

Open keichinger opened 5 years ago

keichinger commented 5 years ago

Sometimes there's a need to set multiple data-attributes when creating a new element. For this I'd prefer to pass in an data object where as each key will be directly set - the same way css is treated.

let element = createElement("div", {
  // works
  "data-a": "a",
  // new! doesn't work (yet?)
  data: {
    b: "b",
    c: "c",
  }
});