v0.15.2: Optimize `.ids`, better type checks,
matAtWork
released this
15 Jul 16:35
·
37 commits
to main
since this release
This release focuses on performance, removing legacy code, and ensuring document
is correctly referenced.
The guide, examples and tests have been updated to reflect the changes, and the enhancements in v0.14.x for iterable objects, arrays and other fixes,
Breaking changes:
- The legacy function
has been removedgetElementIDMap()
- No longer used internally, and it was a slow function as it ended up enumerating a lot of nodes.
- The legacy function
has been removedenableOnRemovedFromDOM()
- To enable this deprecated functionality, pass the flag
enableOnRemovedFromDOM: true
to thetag()
options.
- To enable this deprecated functionality, pass the flag
- The legacy method for creating an element in a non-global document (by specifying it in the tag function attributes) has been removed. You can, if necessary, pass an alternative
document
to thetag()
function options.- This is rarely necessary. The only real use cases are within a shadow DOM or an IFrame. In the latter case it is better if the frame calls
tag()
itself.
- This is rarely necessary. The only real use cases are within a shadow DOM or an IFrame. In the latter case it is better if the frame calls
Optimization
- The implementation of
.ids
has been completely re-written to lazily instantiate a proxy that caches elements keyed by their ID, and it is now a "live" implementation like an HTMLCollection. Assigning to.ids
or any member of it now throws an exception. - Use common
forever
in Iterators.merge/combine to reduce memory footprint
Better types
- Correctly define SpecialWhenEvents as having no members
- Add excess keys test to extended definitions
- add
debugger
non-persistent attribute specifier attributes
is now typed correctly for read (NamedNodeMap) and write (object). The write type doesn't yet enforce the attribute names/types.
Remove global references to document
The library no longer refers to the global document
. You can specify a document
in the TagFunctionOptions, eg: const { div } = tag({ document: frameDocument })
. The default is to use the global document. All other document references are derived from the elements as they are managed. Removing this dependancy means you can create tag functions that work on a different document.
- Add optional TagFunctionOptions['docuemnt'] & 'enableOnRemovedFromDOM' (replaces legacy export)
- Make eventObservations weakly mapped from a document reference
- reference elt.ownerDocument within elementIsInDOM
- Move AI-UI style, resolvedNodes mutationTracker & Dom* functions within tag() call to use the specified document
What's Changed
- v0.15.0 Deprecate legacy calls. Optimize
.ids
. Remove references to globalThis.document. by @matAtWork in #39 - v0.15.1 Correctly escape CSS IDs. by @matAtWork in #41
Full Changelog: Release-v0.14.5...Release-v0.15.2