https://github.com/nomocas/htsl-dom-diffing-pragmatics
Dom Diffing Engine for htsl-lexicon
https://github.com/nomocas/htsl-dom-diffing-pragmatics
Last synced: 3 months ago
JSON representation
Dom Diffing Engine for htsl-lexicon
- Host: GitHub
- URL: https://github.com/nomocas/htsl-dom-diffing-pragmatics
- Owner: nomocas
- Created: 2017-04-22T19:03:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-18T10:35:46.000Z (about 2 years ago)
- Last Synced: 2025-01-21T11:46:01.082Z (4 months ago)
- Language: JavaScript
- Size: 212 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# htsl-dom-diffing-pragmatics
[](https://travis-ci.org/nomocas/htsl-dom-diffing-pragmatics)
[](https://www.bithound.io/github/nomocas/htsl-dom-diffing-pragmatics)
[](https://www.bithound.io/github/nomocas/htsl-dom-diffing-pragmatics/master/dependencies/npm)
[](https://www.bithound.io/github/nomocas/htsl-dom-diffing-pragmatics/master/dependencies/npm)
[](https://conventionalcommits.org)
[]()
[](https://spdx.org/licenses/MIT)Dom Diffing Engine for htsl-lexicon.
- __One of the lightest__ modern pure js html lib avaiable (around 4Ko gzipped with dependencies)
- __One of the fastest DOM diffing engine__ (fastest than Mithril in chrome and firefox - several times faster than React)
- Immutables based comparison.
- Algo that will show excellent behaviour when scalling. More components you have, more optimisation happend.
- Play really well with other libs (redux, immutables, jquery, ...).
- Simple and easy to understand algorithm. No more esoteric interpretation. You are the master.Should be used in conjonction with [htsl-lexicon](https://github.com/nomocas/htsl-lexicon).
Write sentences with lexicon. Interpret them with this pragmatics.
## Usage
```
> yarn i babelute htsl-lexicon htsl-dom-diffing-pragmatics
``````javascript
import htmlLexicon from 'htsl-lexicon';
import 'htsl-dom-diffing-lexicon';const h = htmlLexicon.initializer();
function render(state) {
return h.section(
h.class('my-class')
.h1(state.title)
.div(h.id('my-id'), state.content)
.button('fire !', h.click(state.handler))
);
}const $root = document.getElementById('...');
let oldBabelute,
state = { title:'...', content:'...', handler:(e) => console.log('bouh', e) };
oldBabelute = render(state).$render($root); // first render...
state = { title:'...', content:'...', handler:... };
oldBabelute = render(state).$render($root, oldBabelute); // dif...
oldBabelute.$remove($root); // remove
```
## Licence
The [MIT](http://opensource.org/licenses/MIT) License
Copyright 2017 (c) Gilles Coomans
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.