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 `style` alias for `css` #160

Open keichinger opened 5 years ago

keichinger commented 5 years ago

I find it more intuitive if we'd rename the css key to style — or at least allow both of them — to set the element's inline style. It's closer to the actual HTML attribute.

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", {
  // old
  css: {
    "background-color": "red",
    width: 50,
    height: 50,
  },
  // new! - doesn't work (yet?)
  style: {
    "..."
  }
});