项目作者: glimmerjs

项目描述 :
Library to boot up your Glimmer components as Web Components
高级语言: TypeScript
项目地址: git://github.com/glimmerjs/glimmer-web-component.git
创建时间: 2017-03-26T15:43:10Z
项目社区:https://github.com/glimmerjs/glimmer-web-component

开源协议:MIT License

下载


@glimmer/web-component Build Status

Installation

Add this package to your project with Yarn:

  1. yarn add --dev @glimmer/web-component

Or alternatively with npm:

  1. npm install --save-dev @glimmer/web-component

Usage

Add this import to your src/index.ts or wherever you are instantiating your Glimmer app:

  1. import initializeCustomElements from '@glimmer/web-component';

And then after app.boot():

  1. initializeCustomElements(app, {
  2. 'button-list': 'ButtonList',
  3. 'x-button': 'Button'
  4. });

This will register custom elements for each of the items defined in the hash passed to initializeCustomElements and will replace the custom element with your Glimmer component once the custom element connects. For example, if you provide the hash { 'foo-bar': 'FooBar' }, you can then use the custom element <foo-bar> anywhere in the DOM and have your <FooBar> Glimmer component render in its place.

Browser Support

Browser support for the WebComponents spec is not not great yet. If you want to use customElements.define where it is not yet supported natively, you’ll need to install the polyfill.

License

MIT License.