Skip to content

1.5.3: Support specifying `options` of `document.createElement` in tag functions

Latest
Compare
Choose a tag to compare
@Tao-VanJS Tao-VanJS released this 06 Jan 05:08
· 5 commits to main since this release

This release adds the support of specifying options of document.createElement or document.createElementNS in props argument of tag functions.

Below is an example of using this feature to create a custom button element:

const {button} = van.tags

class MyButton extends HTMLButtonElement {
  connectedCallback() {
    this.addEventListener("click", () => alert("MyButton clicked!"))
  }
}
customElements.define("my-button", MyButton, {extends: "button"})

const CustomButton = () => button({is: "my-button"}, "Click me")

van.add(document.body, CustomButton())

See the release announcement: #290 (comment)