@yhwh-script/elements

1.2.7 • Public • Published

elements

This is a minimalistic, reactive lifecycle implementation of customElements for WebComponents. Check it out!

Installation

It is recommended to use npx

npx @yhwh-script/create-app {YOUR_PROJECT}

However, you can also clone this repository:

   cd elements
   npm install
   npm run dev

How-To

  • create single file HTML components as customElements with <script>, <style> and <template> under ./public/elements/{prefix}/{prefix}-{suffix}.html
  • use them as usual customElements <prefix-suffix>
  • you have access to the shadowDocument and state
  • set state by shadowDocument.host.dataset.state = JSON.stringify({newState})
  • use event bubbling

NO-GOs

  • never addEventListener to shadowDocument

Further reading

Package Sidebar

Install

npm i @yhwh-script/elements

Weekly Downloads

3

Version

1.2.7

License

Unlicense

Unpacked Size

16.2 kB

Total Files

14

Last publish

Collaborators

  • yhwh-script