An open API service indexing awesome lists of open source software.

https://github.com/js-sdk/vdom

An implementation of Virtual DOM great for minimal and stable trees.
https://github.com/js-sdk/vdom

Last synced: about 1 year ago
JSON representation

An implementation of Virtual DOM great for minimal and stable trees.

Awesome Lists containing this project

README

          

# js-sdk-vdom

this is a very simple implementation of the virtual DOM algorithm.

it's a great implementation for short and stable trees (with no much update).

current version compiled size:

- es5 2.1k (1.1k gzipped)
- es2022 1.3k (705 gzipped)

## usage

```js
let tree = null,
state = {};

const target = document.querySelector('#app');

function app(dispatch, state) {
return N(
'button',
{},
{ click: function() { dispatch(new AppEvent()); } },
[T("Click here")]
);
}

function render() {
function dispatch(event) {
// do state management/transition
render();
}

tree = patch(tree, app(dispatch, state), target);
}
```

## license

Released under MIT license. See `license`.