sveltejs/svelte-custom-elements

Name: svelte-custom-elements

Owner: Svelte

Description: Turn Svelte components into web components

Created: 2017-03-02 16:17:06.0

Updated: 2018-05-20 13:44:42.0

Pushed: 2017-09-12 21:04:55.0

Homepage: null

Size: 133

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This project is deprecated ? Svelte can compile directly to custom elements as of version 1.37 (see sveltejs/svelte#797 for more info)


svelte-custom-elements

Register Svelte components as custom elements.

Installation and usage

First, you need to be familiar with Svelte. Read the guide if you haven't already, then come back here!

Install svelte-custom-elements to your project…

install -S svelte-custom-elements

…then use it in your app like so:

rt Counter from './Counter.html';
rt { register } from 'svelte-custom-elements';

ster( 'my-component', Counter, [ 'value' ] );

ment.body.innerHTML = '<my-component value="42"></my-component>';

The register function takes three arguments:

  1. The tag name you wish to use
  2. A Svelte component constructor
  3. An optional list of 'observed attributes'. Any properties that you want to get or set (i.e. component.thing = 'foo') must be included in this list.
Demo
Link / Source

svelte-custom-elements demo

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.