htsl-dom-diffing-pragmatics
v0.3.3
Published
DOM Diffing output engine for htsl-lexicon
Downloads
14
Maintainers
Readme
htsl-dom-diffing-pragmatics
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.
Write sentences with lexicon. Interpret them with this pragmatics.
Usage
> yarn i babelute htsl-lexicon htsl-dom-diffing-pragmatics
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 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.