JSPM

  • Created
  • Published
  • Downloads 39
  • Score
    100M100P100Q91039F
  • License MIT

Evolution-based components with IncrementalDOM templates.

Package Exports

  • @dnajs/idom
  • @dnajs/idom/dist/cjs/idom.js
  • @dnajs/idom/dist/esm/idom.js
  • @dnajs/idom/dist/umd/idom.js

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

Evolution-based components 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>;
    }
}