uhtml v4 - Release notes #86
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


This MR is a partial rewrite of v3 with a "back to origins" purpose and a lot of performance and RAM consumption improvements over the previous stable v3 version.
Please note that while most needed or demanding v3 features will be, eventually, ported over v4, this should be almost a drop-in replacement for v3, with the following most notable breaking changes.
Breaking Changes
uhtml(~2.5K) for default, non-keyed yet blazing fast and most common use cases,uhtml/keyed(~2.6K) for both implicit (default) and explicit keyed operations anduhtml/node(~2.2K) for one-off only use casesonclickor nativeon*handler is just directly set like any other special attribute such asvaluefor inputs or textareas, and so onclassandstyleare handled as special attributes (amongaria,dataandref) so thatclass=${value}now directly setclassNameof the element whilestyle=${value}now directly set theelement.style.cssTextbut only when the current value is different from the previous onehtml.for(...)andhtml.nodeutilities have been moved:uhtml/keyedexport provides anhtmlForand ansvgFordirect callback to create related tags. The full export there is{Hole, render, html, svg, htmlFor, svgFor, attr}and these are all typeduhtml/nodeexport provides a one-off only implementation of the logic, without ever caching details around nodes and without logic around updates ... this export is literally for one-off operations and nothing else, but as escape hatch, creating one-off content can always be done with theuhtml/keyedexport and eitherhtmlFor({})orsvgFor({})utility, still keeping performance high and memory consumption lowstring,boolean,number, or arrays within interpolationshtmlorsvgtags even to create just static text contentreffeatureMemory Improvements
bindfor the very always same callback, helping engines further to optimize for its operations. All other updates use always the exact same callback reference just passing a bit more details than before and the resulting value would update the retained one when that's different from the previous oneAbout TypeScript
This module now generates automatically all definitions in the most accurate way and it describes types also internally, hoping to welcome more TS contributors when it comes to bugs or improvements.