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 casesonclick
or nativeon*
handler is just directly set like any other special attribute such asvalue
for inputs or textareas, and so onclass
andstyle
are handled as special attributes (amongaria
,data
andref
) so thatclass=${value}
now directly setclassName
of the element whilestyle=${value}
now directly set theelement.style.cssText
but only when the current value is different from the previous onehtml.for(...)
andhtml.node
utilities have been moved:uhtml/keyed
export provides anhtmlFor
and ansvgFor
direct callback to create related tags. The full export there is{Hole, render, html, svg, htmlFor, svgFor, attr}
and these are all typeduhtml/node
export 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/keyed
export and eitherhtmlFor({})
orsvgFor({})
utility, still keeping performance high and memory consumption lowstring
,boolean
,number
, or arrays within interpolationshtml
orsvg
tags even to create just static text contentref
featureMemory Improvements
bind
for 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.