@riotjs/custom-elements

9.0.1 • Public • Published

@riotjs/custom-elements

Riot.js custom elements logo

Simple API to create vanilla custom elements with riot

Build Status NPM version NPM downloads MIT License

Demos

Usage

import MyComponent from './my-component.riot'
import define from '@riotjs/custom-elements'

define('x-tag', MyComponent)

Notice that in order to update the component properties via attribute you will need to rely on the observedAttributes array

<my-component>
  <p>{props.message}</p>
  <script>
    export default {
      // the message property will be automatically updated anytime the DOM `message` attribute will change
      observedAttributes: ['message']
    }
  </script>
</my-component>

API

This module exports only a single factory function that is a wrapper around the native customElements.define. The define function accepts only 3 parameters:

  • tag name
  • tag api normally generated via riot compiler
  • custom options to pass to customElements.define like {extends: 'button'} for example

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
9.0.15latest

Version History

VersionDownloads (Last 7 Days)Published
9.0.15
9.0.00
6.0.10
6.0.00
5.0.00
4.1.10
4.1.01
4.0.00
4.0.0-beta.10
4.0.0-alpha.31
4.0.0-alpha.20
4.0.0-alpha.11
0.1.00
0.0.10
0.0.00

Package Sidebar

Install

npm i @riotjs/custom-elements

Weekly Downloads

8

Version

9.0.1

License

MIT

Unpacked Size

13 kB

Total Files

5

Last publish

Collaborators

  • gianlucaguarini