JSPM

  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q90937F
  • License MIT

Just another components pattern with IncrementalDOM templates.

Package Exports

  • @dnajs/idom

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dnajs/idom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Logo

Just another components pattern with IncrementalDOM templates.

Documentation | Issue tracker | Project home page | Author home page

Install

NPM

$ npm i @dnajs/idom --save

Usage

Defining a template using IDOM.h

IDOM.h is a wrapper for IncrementalDOM api:

// my-component.js
import { BaseComponent, IDOM } from '@dnajs/idom';

export class MyComponent extends BaseComponent {
    get template() {
        return () => IDOM.h('span', 'Hello!');
    }
}

it will look like:

<my-component>
    <span>Hello!</span>
</my-component>

With JSX!

JSX support is provided too, passing IDOM.h as pragma.

$ npm install babel-plugin-transform-react-jsx -D
// .babelrc
...
    "plugins": [
        ...,
        ["transform-react-jsx", { "pragma": "IDOM.h" }],
        ...
    ]
...
// my-component.js
import { BaseComponent, IDOM } from '@dnajs/idom';

export class MyComponent extends BaseComponent {
    get template() {
        return <span>Hello!</span>;
    }
}

IncrementalDOM notifications

You can use IncrementalDOM notifications to trigger components' life cycle callbacks. This will save you from import heavy polyfills for Custom Elements support if your application is built entirely with DNA or IncrementalDOM.

In order to activate IncrementalDOM notifications, import the observer.js file in your application:

import '@dnajs/idom/observer.js';