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.
- Host: GitHub
- URL: https://github.com/js-sdk/vdom
- Owner: js-sdk
- License: mit
- Created: 2022-07-10T20:56:59.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-15T01:12:34.000Z (about 3 years ago)
- Last Synced: 2025-03-16T02:40:30.578Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 485 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
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`.