NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #3682 most downloaded on npm
HTML templates literals in JavaScript
Last release 4 months ago
14 May 2026
Ships fairly regularly
a new release about every 2 months
Nearly every release is documented
notes for 58 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
107 releases · first in 2017
### Patch Changes - #5218 `be6b275035079db3239be4019c4f93c2b1f32428` Thanks @louis-bompart! - Ensure the ref directive disconnect gracefuly when its i
be6b275035079db3239be4019c4f93c2b1f32428 Thanks @louis-bompart! - Ensure the ref directive disconnect gracefuly when its internal ref is undefined.### Patch Changes - #5044 `0d0170e87b06edd8295a31893c820162d0f16a23` Thanks @ava-cassiopeia! - Make ClassInfo mutable - #5064 `bc2926eb99a97ef4efb7eef
#5044 0d0170e87b06edd8295a31893c820162d0f16a23 Thanks @ava-cassiopeia! - Make ClassInfo mutable
#5064 bc2926eb99a97ef4efb7eefbe133d6a33f216e18 Thanks @brysonbw! - Add SVGElement to the render() container type, allowing SVG elements to be used as render roots without type errors.
#5035 c36626b8018ca78a47e61abdfa5b5904bed06843 - Make some of our directives generic, so that their DirectiveResult types capture everything needed to infer their render types. This is useful in template type checking.
One column per quarter.
### Patch Changes - #4997 `aea85e24` - Update README - #4988 `6792b7ef` Thanks @ADNolan! - Adjusted the comparison to use the name property of the \_$
### Minor Changes - #4901 `c9160405` Thanks @maxpatiiuk! - Dev mode warnings are now emitted on the next microtask after package import, allowing for
c9160405 Thanks @maxpatiiuk! - Dev mode warnings are now emitted on the next microtask after package import, allowing for a wider opportunity to suppress the warnings by consumers.0a9bc720 Thanks @louis-bompart! - Import barrels explicitly for compatibility with modern Node resolution w/ ESM25962bf5 Thanks @kyubisation! - Implement SSR event handling and an optional flag globalThis.litSsrCallConnectedCallback to call connectedCallback during SSR, if set to true.25962bf5]:
### Patch Changes - #4782 `99703a03` - Revert the Terser plugin for Rollup to rollup-plugin-terser from @rollup/plugin-terser due to a bug that preven
### Minor Changes - #4637 `feccc1ba` - Add MathML support with the mathml template tag
011b762d - Add a server-only html function, to define templates that will only be rendered on the server.### Patch Changes - #4646 `abf30b3e` - The value provided by the ref() directive will always be undefined when the element is disconnected.
### Patch Changes - #4570 `bd881370` - Fix the lit-html marker length to be consistently 9 characters.
### Patch Changes - #4523 `1a32b61e` - Add a DEV_MODE error to catch duplicate attribute bindings that otherwise create silent errors. - #4485 `57b006
#4523 1a32b61e - Add a DEV_MODE error to catch duplicate attribute bindings that otherwise create silent errors.
#4485 57b00630 - Add "browser" export condition entrypoints to any package.json files with "node"
export conditions. This fixes Node test runners emulating browser environments that were incorrectly loading the
"node" entrypoints instead of the browser code.
#4515 dca963f7 - Fix a memory leak when patching directive constructors for SSR.
### Patch Changes - #4409 `1af7991c` - asyncReplace correctly re-renders when value is unchanged
### Minor Changes - #4309 `949a5467` - Adds two new types: UncompiledTemplateResult and MaybeCompiledTemplateResult. Currently UncompiledTemplateResul
04c8d65a - Graduate @lit-labs/task to @lit/task, its permanent location. @lit-labs/task is now just a proxy for @lit/task, so code need not be duplicated in projects that depend on both.### Patch Changes - #4345 `02b8d620` - Add a dev mode warning if a static value such as literal or unsafeStatic is detected within the non-static html
### Patch Changes - #4240 `edf998c9` Thanks @remziatay! - Improved the type inferece of the choose() directive to properly restrict the case type infe
#4240 edf998c9 Thanks @remziatay! - Improved the type inferece of the choose() directive to properly restrict the case type inferred from provided value. Note: If this change creates a type error in your code, there must have been an unreachable case that can be removed, or the type of your value might be missing a valid case in the union.
#4310 8f674ab3 Thanks @megheaiulian! - The when() directive now calls the case functions with the provided condition value as an argument. This allows the narrowing of types for the condition value based on its truthiness when used as a parameter for the case function.
3be62b07 Thanks @mlcui-google! - Fix Task.render()'s return type always being undefined### Major Changes - #3756 `f06f7972` - Drop IE11 support - #3759 `1db01376` - Use replaceWith() for SVG templates - #3765 `92cedaa2` - Remove experime
#3765 92cedaa2 - Remove experimental hydrate modules. These are available from @lit-labs/ssr-client.
#3751 dfd747cf - Simplify lit-html attribute handling for standards-compliant browsers that iterate attributes in source order
#3750 c3e473b4 - Use toggleAttribute() to simplify boolean attribute parts
#4004 5beb5f9a - Adds the 'afterUpdate' option for autoRun to Task, and runs tasks by default in hostUpdate() instead of hostUpdated(). 'afterUpdate' is needed to run tasks dependent on DOM updates, but will cause multiple renders of the host element.
#4013 a5bf2507 - Add pluggable task args equality functions and deepArrayEquals. Breaking: this removes performTask() and shouldRun() protected methods.
Most users should no longer import directly from lit-element, and instead prefer importing LitElement from the lit packages. The default entry point for lit-element remains backward-compatible and includes all decorators. However, it's recommended to use import {LitElement} from 'lit'; and import decorators from lit/decorators as necessary. See the Upgrade Guide for more details.
UpdatingElement has been moved from the lit-element package to the @lit/reactive-element package and renamed to ReactiveElement. See the ReactiveElement API documentation for more details. In addition, the source for css-tag, and all decorators have been moved to @lit/reactive-element. However, all symbols are re-exported from both lit and lit-element packages.
The @internalProperty decorator has been renamed to @state.
Errors that occur during the update cycle were previously squelched to allow subsequent updates to proceed normally. Now errors are re-fired asynchronously so they can be detected. Errors can be observed via an unhandledrejection event handler on window.
The lib folder has been removed.
Rendering of renderRoot/shadowRoot) via createRenderRoot and support for static styles has moved from LitElement to ReactiveElement.
The createRenderRoot method is now called just before the first update rather than in the constructor. Element code can not assume the renderRoot exists before the element hasUpdated. This change was made for compatibility with SSR.
ReactiveElement's initialize method has been removed. This work is now done in the element constructor.
The static render has been removed.
For consistency, renamed _getUpdateComplete to getUpdateComplete.
When a property declaration is reflect: true and its toAttribute function returns undefined the attribute is now removed where previously it was left unchanged (#872).
The dirty check in attributeChangedCallback has been removed. While technically breaking, in practice it should very rarely be (#699).
LitElement's adoptStyles method has been removed. Styling is now adopted in createRenderRoot. This method may be overridden to customize this behavior.
LitElement's static getStyles method has been renamed to static finalizeStyles and now takes a list of styles the user provided and returns the styles which should be used in the element. If this method is overridden to integrate into a style management system, typically the super implementation should be called.
Removed build support for TypeScript 3.4.
Decorators are no longer exported from the lit-element module. Instead, import any decorators you use from lit/decorators/*.
lit-html has been updated to 2.x.
Support for running in older browsers has been removed from the default configuration. Import the platform-support module to support Shady DOM. Note also that Lit parts inside <style> elements are no longer supported. See Polyfills for more details.
For simplicity, requestUpdate no longer returns a Promise. Instead await the updateComplete Promise.
Removed requestUpdateInternal. The requestUpdate method is now identical to this method and should be used instead.
#2103 15a8356d - Updates the exports field of package.json files to replace the subpath
folder
mapping
syntax with an explicit list of all exported files.
The /-suffixed syntax for subpath folder mapping originally used in these
files is deprecated. Rather than update to the new syntax, this change replaces
these mappings with individual entries for all exported files so that (a) users
must import using extensions and (b) bundlers or other tools that don't resolve
subpath folder mapping exactly as Node.js does won't break these packages'
expectations around how they're imported.
renderOptions class field now exists on LitElement and can be set/overridden to modify the options passed to lit-html.static shadowRootOptions for customizing shadowRoot options. Rather than implementing createRenderRoot, this property can be set. For example, to create a closed shadowRoot using delegates focus: static shadowRootOptions = {mode: 'closed', delegatesFocus: true}.development Node exports condition. See Development and production builds for more details.f43b811 - Don't publish src/ to npm.css function now maintains a cache and will use a cached value if available when the same style text is requested.static get properties on an undefined superclass with @property on a subclass ([#890]https://github.com/Polymer/lit-element/issues/890));### Minor Changes - #4081 `d27a77ec` - Sync from last stable release ### Patch Changes - #4141 `6b515e43` - Update TypeScript to ~5.2.0
### Major Changes - #3751 `dfd747cf` - Simplify lit-html attribute handling for standards-compliant browsers that iterate attributes in source order -
#3751 dfd747cf - Simplify lit-html attribute handling for standards-compliant browsers that iterate attributes in source order
#3750 c3e473b4 - Use toggleAttribute() to simplify boolean attribute parts
#3765 92cedaa2 - Remove experimental hydrate modules. These are available from @lit-labs/ssr-client.
### Minor Changes - #3993 `e2c50569` - Fix return type of isTemplateResult helper to include the CompiledTemplateResult and fix the cache directive to
### Patch Changes - #3968 `5bb40831` - Allow undefined to be passed to the ref() directive - #3969 `7d8d4a15` - Make RefOrCallback generic like Ref -
#3968 5bb40831 - Allow undefined to be passed to the ref() directive
#3987 bb2560f1 - Change the h field of CompiledTemplates to a TemplateStringsArray preventing the spoofing of CompiledTemplates by JSON injection attacks. This should not be a breaking change for most users unless you're using CompiledTemplates. This is a necessary security fix, similar to #2307.
### Patch Changes - #3888 `0f30e6fb` - Fix a memory leak cause by lit-html's shared TreeWalker holding a reference to the last tree it walked.
### Patch Changes - #3825 `343187b1` - static-html no longer adds an item to TemplateResult's value array for the last consumed static value. This fix
### Patch Changes - #3788 `88fe0390` - Allow numbers to be used as values in styleMap()
The modules in the original location have been marked deprecated and will be removed in a future version.
Note: @lit-labs/ssr and lit-html must be updated together.
### Patch Changes - #3526 `65e56655` - Disable ShadyDOM noPatch in Node dev build. This fixes the issue of throwing due to undefined window.
The new @lit-labs/ssr-dom-shim package has been introduced, which exports an HTMLElement, CustomElementRegistry, and default customElements singleton.
#3522 72fcf0d7 - When running in Node, Lit now automatically includes minimal DOM shims which are
sufficient for most SSR (Server Side Rendering) use-cases, removing the need to
import the global DOM shim from @lit-labs/ssr.
The new @lit-labs/ssr-dom-shim package has been introduced, which exports an HTMLElement, CustomElementRegistry, and default customElements singleton.
The existing @lit-labs/ssr global DOM shim can still be used, and is compatible with the new package, because @lit-labs/ssr imports from @lit-labs/ssr-dom-shim. Importing the global DOM shim adds more APIs to the global object, such as a global HTMLElement, TreeWalker, fetch, and other APIs. It is recommended that users try to remove usage of the @lit-labs/ssr DOM shim, and instead rely on the more minimal, automatic shimming that @lit/reactive-element now provides automatically.
### Minor Changes - #3507 `b152db29` - lit-html and reactive-element now include development Node builds with unminified code and dev warnings.
### Minor Changes - #3318 `21313077` - Adds an isServer variable export to lit and lit-html/is-server.js which will be true in Node and false in the b
### Patch Changes - #3223 `5a65ca97` - Use existing document in Node build
Most commonly this would happen when rendering ${this} in a LitElement's template, which has the counterintuitive behavior of removing the element fro
ae6f6808 - Lit and its underlying libraries can now be imported directly from Node without crashing, without the need to load the @lit-labs/ssr dom-shim library. Note that actually rendering from a Node context still requires the @lit-labs/ssr dom-shim, and the appropriate integration between @lit-labs/ssr and your framework/tool.#3003 daddeb34 - Lit's async-directive now re-exports everything from the directive module.
#3199 0725fdb4 - In DEV_MODE, render a warning instead of rendering a template's host in the template.
Most commonly this would happen when rendering ${this} in a LitElement's template, which has the counterintuitive behavior of removing the element from the DOM, because when rendering the element's template we attach it into its own shadow root, which removes it from the DOM, causing it simply disappear. This is especially problematic with a fast HMR system.
#3186 3766ae4c - StaticValue interface type is now exported.
Nothing published for this version
Nothing published for this version
### Patch Changes - #3130 `1f0567f1` - Export the underlying type of the keyed directive. - #3132 `2fe2053f` - Added "types" entry to package exports.
### Patch Changes - #2849 `b12e8d93` - Expand documentation for render and TemplateResult.
### Patch Changes - #2952 `a78cc3b7` - Fix SSR hydration bug relating to and other void elements having attribute bindings.
### Patch Changes - #2847 `79d82385` - Fix typo in API docs for live() directive. - #2828 `b3b6bc33` - Remove private Lit 2 migration helpers: INTERNA
### Patch Changes - #2732 `3e181bcb` - Enforce use of file extensions in imports. Fixes an issue with older TypeScript compilers.
### Patch Changes - #2657 `a6069c40` - Remove readonly restriction from StyleInfo interface as addition, deletion, and updating of styles is valid. Ex
#2657 a6069c40 - Remove readonly restriction from StyleInfo interface as addition, deletion, and updating of styles is valid. Expanded styleMap documentation with links to lit.dev.
#2642 badc532c - Add an additional security brand check to StaticValues; Similar to #2307
#2691 171143bd - Fixes ref bug when auto-bound class method used as a callback could incorrectly receive undefined.
#2661 9a3a38cd - Give a clearer error message when rendering into null/undefined
#2646 365cd09a - Clarify that hacking around the template strings array brand error can create security vulnerabilities.
### Patch Changes - #2635 `ae358703` - Make the event debug logger lazier, doing even less work (with no side effects) even in dev mode unless the pag
### Minor Changes - #2401 `2c9d0008` - Added a devlog events system that may be used for debugging and visualizing Lit's internals.
Updated dependencies \[`57b00630`]:
57b00630 - Add "browser" export condition entrypoints to any package.json files with "node"
export conditions. This fixes Node test runners emulating browser environments that were incorrectly loading the
"node" entrypoints instead of the browser code.57b00630]:
### Patch Changes - #4340 `18305b43` - Update dependency version range on graduated package to ^1.0.0 so this package can receive updates.
Updated dependencies \[`3ac01aee`]:
### Minor Changes - #4901 `c9160405` Thanks @maxpatiiuk! - Dev mode warnings are now emitted on the next microtask after package import, allowing for
#4901 c9160405 Thanks @maxpatiiuk! - Dev mode warnings are now emitted on the next microtask after package import, allowing for a wider opportunity to suppress the warnings by consumers.
#4934 4824c4ce - Adds property option for useDefault. When set, the initial default value is not considered a change and does not reflect when reflect is set. In addition, when the attribute is removed, the default value is restored.
5a60fbc6 Thanks @rivajunior! - export Options interface### Patch Changes - #4387 `bf551b5b` - Ensure renderRoot exists before first update (#4268) - #4282 `c7922a0c` Thanks @MaxArt2501! - Fix a bug where a
#4387 bf551b5b - Ensure renderRoot exists before first update (#4268)
#4282 c7922a0c Thanks @MaxArt2501! - Fix a bug where accessing a @query decorated field with the cache flag set before the first update would result in null being cached permanently. null will no longer be cached before the first update and in DEV_MODE now raises a warning.
#4388 839ca0f8 - Fixes bug where adding or removing controllers during a reactive controller lifecycle would affect the execution of other controllers (#4266). Controllers can now be added/removed during lifecycle without affecting others.
### Patch Changes - #4520 `89c5bdfb` - Update typescript dependency
### Major Changes - #3850 `7e8491d4` - Remove transform for deprecated usage of queryAssignedNodes. - #4141 `6b515e43` - Update TypeScript to ~5.2.0,
#4146 0f6878dc - Generated accessor for reactive properties now wrap user accessors and automatically call this.requestUpdate() in the setter. As in previous versions, users can still specify noAccessor: true, in which case they should call this.requestUpdate() themselves in the setter if they want to trigger a reactive update.
#4254 1040f758 - Change the type of ReactiveElement.renderRoot and return type of ReactiveElement.createRenderRoot() to be HTMLElement | DocumentFragment to match each other and lit-html's render() method.
#3850 7e8491d4 - Delete deprecated queryAssignedNodes behavior and arguments.
Migrate deprecated usage with a selector argument to use
@queryAssignedElements. E.g.: @queryAssignedNodes('list', true, '.item') to
@queryAssignedElements({slot: '', flatten: false, selector: '.item'}).
#4027 c28cb6ed - - [BREAKING] Removed deprecated call signature for createComponent() taking multiple arguments. A single option object must be passed in instead.
Example:
- createComponent(React, 'my-element', MyElement, {onfoo: 'foo'})
+ createComponent({
+ react: React,
+ tagName: 'my-element',
+ elementClass: MyElement,
+ events: {onfoo: 'foo'},
+ })
forwardRef rather than creating a class component. This removes an extra React component of the same name showing up in the component tree.LitElement, ReactiveElement, and lit-html). See the Migration Guide for more details.The templateFactory option of RenderOptions has been removed.
TemplateProcessor has been removed.
Symbols are not converted to a string before mutating DOM, so passing a Symbol to an attribute or text binding will result in an exception.
The shady-render module has been removed and is now part of platform-support, and Lit's polyfill support now adds the following limitations: (1) Bindings in style elements are no longer supported. Previously these could not change and in the future they may be supported via static bindings. (2) ShadyCSS.styleElement is no longer called automatically. This must be called whenever dynamic changes that affect styling are made that involve css custom property shimming (older browsers) or changes to custom properties used via the deprecated @apply feature. It was previously called only on first render, and it is now up to the user to decide when this should be called. See Polyfills for more details.
render() no longer clears the container it's rendered to. It now appends to the container by default.
Expressions in comments are no longer rendered or updated. See Valid expression locations for more details.
Template caching happens per callsite, not per template-tag/callsize pair. This means some rare forms of highly dynamic template tags are no longer supported.
Arrays and other iterables passed to attribute bindings are not specially handled. Arrays will be rendered with their default toString representation. This means that html`<div class=${['a', 'b']}> will render <div class="a,b"> instead of <div class="a b">. To get the old behavior, use array.join(' ').
Multiple bindings in a single attribute value don't require the attribute value is quoted, as long as there is no whitespace or other attribute-ending character in the attribute value. html`<div id=${a}-${b}>`
The directive and part APIs are significantly different. See Custom Directives and the Upgrade Guide for more details.
The Directive base class and directive() factory function are
now exported from the lit-html/directive.js module.
NodePart has been renamed to ChildPart,
along with other methods and variables that use the "Node" naming, like
PartType.Node which is now PartType.CHILD.
The part exports (ChildPart,
AttributePart, etc) have been change to interface-only exports. The constructors are no longer exported. Directive authors should use helpers in directive-helpers.js to construct parts.
The eventContext render option has been changed to host.
#2103 15a8356d - Updates the exports field of package.json files to replace the subpath
folder
mapping
syntax with an explicit list of all exported files.
The /-suffixed syntax for subpath folder mapping originally used in these
files is deprecated. Rather than update to the new syntax, this change replaces
these mappings with individual entries for all exported files so that (a) users
must import using extensions and (b) bundlers or other tools that don't resolve
subpath folder mapping exactly as Node.js does won't break these packages'
expectations around how they're imported.
#1764 0b4d6eda - Don't allow classMap to remove static classes. This keeps classMap consistent with building a string out of the classnames to be applied.
renderBefore to render options. If specified, content is rendered before the node given via render options, e.g. {renderBefore: node}.development Node exports condition. See Development and production builds for more details.instanceof has been removed, making rendering more likely to
work when multiple instances of the library interact.render now returns the ChildPart that was created/updated by render.AsyncDirective, which is a Directive subclass whose
disconnected callback will be called when the part containing the directive
is cleared (or transitively cleared by a Part higher in the tree) or manually
disconnected using the setConnected API, and whose reconnected callback
will be called when manually re-connected using setConnected. When
implementing disconnected, the reconnected callback should also be
implemented to return the directive to a usable state. Note that LitElement
will disconnect directives upon element disconnection, and re-connect
directives upon element re-connection. See Async directives for more details.setConnected(isConnected: boolean) to ChildPart; when called with
false, the disconnected callback will be run on any directives contained within
the part (directly or transitively), but without clearing or causing a
re-render to the tree. When called with true, any such directives'
reconnected callback will be called prior to its next update/render
callbacks. Note that LitElement will call this method by default on the
rendered part in its connectedCallback and disconnectedCallback.static-html module, a static html tag function, a literal tag function, and unsafeStatic(), which allows template authors to add strings to the
static structure of the template, before it's parsed as HTML. See Static expressions for more details.lit-html/directive-helpers.js module with helpers for creating custom directives. See Custom directives for more details.null, undefined, or empty string in a ChildPart now has the same affect as rendering nothing: it does not produce an empty text node. When rendering into an element with Shadow DOM, this makes it harder to inadvertently prevent <slot> fallback content from rendering.noChange are now unchanged. This
allows the guard directive to guard directive values (#1519).creationScope to RenderOptions, which controls the node from which the template is cloned from.#1922 8189f094 - Binding noChange into an interpolated attribute expression now no longer removes the attribute on first render - instead it acts like an empty string. This is mostly noticable when using until() without a fallback in interpolated attributes.
#2070 a48f39c8 - Throw instead of rendering an innocuous value into a style or script when security hooks are enabled.
#2044 662209c3 - Improves disconnection handling for first-party AsyncDirectives (until, asyncAppend, asyncReplace) so that the directive (and any DOM associated with it) can be garbage collected before any promises they are awaiting resolve.
The /-suffixed syntax for subpath folder mapping originally used in these files is deprecated. Rather than update to the new syntax, this change repla…
b3121ab7 - Fix ChildPart parentNode for top-level parts to return the parentNode they will be inserted into, rather than the DocumentFragment they were cloned into. Fixes #2032.#2103 15a8356d - Updates the exports field of package.json files to replace the subpath
folder
mapping
syntax with an explicit list of all exported files.
The /-suffixed syntax for subpath folder mapping originally used in these
files is deprecated. Rather than update to the new syntax, this change replaces
these mappings with individual entries for all exported files so that (a) users
must import using extensions and (b) bundlers or other tools that don't resolve
subpath folder mapping exactly as Node.js does won't break these packages'
expectations around how they're imported.
d6b385e3 - (Cleanup) Added missing tests to close out TODOs in the code.
Fixed unsafeHTML and unsafeSVG to render no content (empty string) for values undefined, null, and nothing.8189f094 - Binding noChange into an interpolated attribute expression now no longer removes the attribute on first render - instead it acts like an empty string. This is mostly noticable when using until() without a fallback in interpolated attributes.b4bd9f7c - Parts are not supported inside the template or textarea tags. In dev mode, we indicate if parts are placed here so the developer can remove them.7adfbb0c - Remove unneeded matches support in @queryAssignedNodes. Update styling tests to use static bindings where needed. Fix TODOs related to doc links.0b4d6eda - Don't allow classMap to remove static classes. This keeps classMap consistent with building a string out of the classnames to be applied.a48f39c8 - Throw instead of rendering an innocuous value into a style or script when security hooks are enabled.724a9aab - Ensures dev mode warnings do not spam by taking care to issue unique warnings only once.e5667d66 - Fixed issue where AsyncDirectives could see this.isConnected === true if a LitElement performed its initial render while it was disconnected.043a16fb - In development mode, constructing an EventPart from an improperly formed attribute will now throw: the attribute must contain only a single expression and the surrounding two strings must be the empty string. Before, constructing an EventPart with extra expressions or surrounding text would cause that part to be silently and incorrectly treated as an AttributePart.Changes below were based on the Keep a Changelog format. All changes above are generated automatically by Changesets.
69389958 - Changed all prefixes used for minifying object and class properties from greek
characters to ASCII, to avoid requiring an explicit script charset on some
browser/webview environments.ff0d1556 - Fixes polyfill-support styling issues: styling should be fully applied by firstUpdated/update time; late added styles are now retained (matching Lit1 behavior)5768cc60 - Reverts the change in Lit 2 to pause ReactiveElement's update cycle while the element is disconnected. The update cycle for elements will now run while disconnected as in Lit 1, however AsyncDirectives must now check the this.isConnected flag during update to ensure that e.g. subscriptions that could lead to memory leaks are not made when AsyncDirectives update while disconnected.c8fe1d4 - For minified class fields on classes in lit libraries, added prefix to stable properties to avoid collisions with user properties.6938995 - Changed prefix used for minifying class field names on lit libraries to stay within ASCII subset, to avoid needing to explicitly set the charset for scripts in some browsers.f05be301 - Fixed bug where Template.createElement was not patchable by polyfill-support when compiled using closure compiler, leading to incorrect style scoping.56e8efd3 - Fixed an error thrown when an empty <style></style> tag is rendered while using the @apply shim under native Shadow DOM.662209c3 - Improves disconnection handling for first-party AsyncDirectives (until, asyncAppend, asyncReplace) so that the directive (and any DOM associated with it) can be garbage collected before any promises they are awaiting resolve.a791514b - Properties that must remain unminified are now compatible with build tools other than rollup/terser.Changes below were based on the Keep a Changelog format. All changes above are generated automatically by Changesets.
<!-- PRs should document their user-visible changes (if any) in the Unreleased section, uncommenting the header as necessary. -->
<!-- ## [X.Y.Z] - YYYY-MM-DD --> <!-- ## Unreleased --> <!-- ### Changed --> <!-- ### Added --> <!-- ### Fixed --> <!-- ### Removed -->
### Fixed - Exported the Ref interface.
Ref interface.Add dependency on trustedtypes typings.
Experimental modules may undergo breaking changes within otherwise non-major releases.
defer-hydration attribute handling to experimental-hydrate, which helps
coordinate ordered wakeup of custom elements during hydration.hydrate module to experimental-hydrate to reflect its experimental nature. Experimental modules may undergo breaking changes within otherwise non-major releases.Added optional creationScope to RenderOptions, which controls the node from which the template is cloned from.
creationScope to RenderOptions, which controls the node from which the template is cloned from.SVGTemplateResult type.
(#1623)(Since 2.0.0-pre.4) Added asyncappend and asyncReplace directives.
asyncappend and asyncReplace directives.noChange are now unchanged. This
allows the guard directive to guard directive values (#1519).klass argument from isDirectiveResult since it is generally not version-agnostic to test directives using instanceof. A new getDirectiveClass helper is introduced, which allows for directive class branding checks instead.DisconnectableDirective was renamed to AsyncDirective, and its module name was renamed from disconnectable-directive to async-directive.null, undefined, or empty string in a ChildPart now has the same affect as rendering nothing: it does not produce an empty text node. When rendering into an element with Shadow DOM, this makes it harder to inadvertently prevent <slot> fallback content from rendering.DisconnectableDirective's disconnectedCallback and reconnectedCallback were renamed to disconnected and reconnected.platform-support to polyfill-support.Nothing published for this version
render now returns the NodePart that was created/updated by render.
render now returns the NodePart that was created/updated by render.
Added DisconnectableDirective, which is a Directive subclass whose
disconnectedCallback will be called when the part containing the directive
is cleared (or transitively cleared by a Part higher in the tree) or manually
disconnected using the setConnected API, and whose reconnectedCallback
will be called when manually re-connected using setConnected. When
implementing disconnectedCallback, reconnectedCallback should also be
implemented to return the directive to a usable state. Note that LitElement
will disconnect directives upon element disconnection, and re-connect
directives upon element re-connection.
Added setConnected(isConnected: boolean) to NodePart; when called with
false, disconnectedCallback will be run on any directives contained within
the part (directly or transitively), but without clearing or causing a
re-render to the tree. When called with true, any such directives'
reconnectedCallback will be called prior to its next update/render
callbacks. Note that LitElement will call this method by default on the
rendered part in its connectedCallback and disconnectedCallback.
Added unsafeStatic(), which allows template authors to add strings to the
static structure of the template, before it's parsed as HTML.
Added isPrimitive(), isTemplateResult(), and isDirectiveResult() to lit-html/directive-helpers.js.
Directives that asynchronously update their part value must now
extend DisconnectableDirective and call this.setValue(), a new API exposed
on the DisconnectableDirective class. Directives that render synchronously
to their update lifecycle should simply return the value to be committed to
their part from update/render.
The Directive base class and directive() factory function are
now exported from the lit-html/directive.js module.
(since 2.0.0-pre.3) The Part type constants (NODE_PART, etc) are
removed from the main lit-html module and exported as an enum-object named
PartType from lit-html/directive.js. Use PartType.NODE instead of
NODE_TYPE.
(since 2.0.0-pre.3)) lit-html/parts.js has been renamed to
lit-html/directive-helpers.js.
(since 2.0.0-pre.3)) Originally in lit-html/parts.js,
createAndInsertPart() and insertPartBefore() have been combined into a single insertPart() function in lit-html/directive-helpers.js. detachNodePart() and restoreNodePart() have been removed in favor of moving parts with insertPart().
(since 2.0.0-pre.3) NodePart has been renamed to ChildPart,
along with other methods and variables that use the "Node" naming, like
PartType.Node which is now PartType.CHILD.
(since 2.0.0-pre.3) The DirectiveClass, DirectiveParameters
and PartInfo types have been moved from lit-html to
lit-html/directive.ts.
(since 2.0.0-pre.3) The part exports (ChildPart,
AttributePart, etc) have been change to interface-only exports. The constructors are no longer exported. Directive authors should use helpers in directive-helpers.js to construct parts.
(since 2.0.0-pre.3) The setPartValue function in
directive-helpers.js has been renamed to setChildPartValue and now only
supports ChildParts. Directives that require updating their container
part outside the render/update lifecycle should extend
DisconnectableDirective and use this.setValue().
(since 2.0.0-pre.3) The eventContext render option has been changed to host.
<!-- ### Fixed --> <!-- ### Removed -->
The shady-render module has been removed and is now part of platform-support. There are also a couple of breaking changes. (1) Bindings in style eleme…
shady-render module has been removed and is now part of platform-support. There are also a couple of breaking changes. (1) Bindings in style elements are no longer supported. Previously these could not change and in the future they may be supported via static bindings. (2) ShadyCSS.styleElement is no longer called automatically. This must be called whenever dynamic changes that affect styling are made that involve css custom property shimming (older browsers) or changes to custom properties used via the deprecated @apply feature. It was previously called only on first render, and it is now up to the user to decide when this should be called.render() no longer clears the container it's rendered to. It now appends to the container by default.html`<div class=${['a', 'b']}> will render <div class="a,b"> instead of <div class="a b">. To get the old behavior, use array.join(' ').html`<div id=${a}-${b}>renderBefore to render options. If specified, content is rendered before the node given via render options, e.g. {renderBefore: node}.development Node exports condition. See README.md for more details.instanceof has been removed, making rendering more likely to
work when multiple instances of the library interact.templateFactory option of RenderOptions has been removed.asyncAppend and asyncReplace directives are not implemented.Nothing published for this version
### Major Changes - #4141 `6b515e43` - Update TypeScript to ~5.2.0
#4146 0f6878dc - Generated accessor for reactive properties now wrap user accessors and automatically call this.requestUpdate() in the setter. As in previous versions, users can still specify noAccessor: true, in which case they should call this.requestUpdate() themselves in the setter if they want to trigger a reactive update.
#4183 6470807f - Make the decorators work with the accessor keyword when experimentalDecorators is true.
Nothing published for this version
### Minor Changes - #4987 `3ac01aee` - Implement the full CustomElementRegistry type for the ssr shim. Improves fidelity and compilability.
Your coding agent can read these notes before it upgrades. Set up the MCP server →