JSPM

  • Created
  • Published
  • Downloads 37
  • Score
    100M100P100Q91577F
  • 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 IncrementalDOM

An IncrementalDOM template for DNA components is a wrapping function around the api calls:

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

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

it will look like:

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

JSX support is provided too, thanks to the babel-plugin-incremental-dom:

// .babelrc
...
    "plugins": [
        ...,
        ["incremental-dom", { "prefix": "IDOM" }],
        ...
    ]
...
// 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';