- New package serving as the main entry point for all users of Lit (including
LitElement,ReactiveElement, andlit-html). See the Migration Guide for more details.
-
Most users should no longer import directly from
lit-element, and instead prefer importingLitElementfrom thelitpackages. The default entry point forlit-elementremains backward-compatible and includes all decorators. However, it's recommended to useimport {LitElement} from 'lit';and import decorators fromlit/decoratorsas necessary. See the Upgrade Guide for more details. -
UpdatingElementhas been moved from thelit-elementpackage to the@lit/reactive-elementpackage and renamed toReactiveElement. See the ReactiveElement API documentation for more details. In addition, the source forcss-tag, and alldecoratorshave been moved to@lit/reactive-element. However, all symbols are re-exported from bothlitandlit-elementpackages. -
The
@internalPropertydecorator 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
unhandledrejectionevent handler on window. -
The
libfolder has been removed. -
Rendering of
renderRoot/shadowRoot) viacreateRenderRootand support forstatic styleshas moved fromLitElementtoReactiveElement. -
The
createRenderRootmethod is now called just before the first update rather than in the constructor. Element code can not assume therenderRootexists before the elementhasUpdated. This change was made for compatibility with SSR. -
ReactiveElement'sinitializemethod has been removed. This work is now done in the element constructor. -
The static
renderhas been removed. -
For consistency, renamed
_getUpdateCompletetogetUpdateComplete. -
When a property declaration is
reflect: trueand itstoAttributefunction returnsundefinedthe attribute is now removed where previously it was left unchanged (#872). -
The dirty check in
attributeChangedCallbackhas been removed. While technically breaking, in practice it should very rarely be (#699). -
LitElement's
adoptStylesmethod has been removed. Styling is now adopted increateRenderRoot. This method may be overridden to customize this behavior. -
LitElement's
static getStylesmethod has been renamed tostatic finalizeStylesand 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 thesuperimplementation should be called. -
Removed build support for TypeScript 3.4.
-
Decorators are no longer exported from the
lit-elementmodule. Instead, import any decorators you use fromlit/decorators/*. -
lit-htmlhas been updated to 2.x. -
Support for running in older browsers has been removed from the default configuration. Import the
platform-supportmodule to support Shady DOM. Note also that Lit parts inside<style>elements are no longer supported. See Polyfills for more details. -
For simplicity,
requestUpdateno longer returns a Promise. Instead await theupdateCompletePromise. -
Removed
requestUpdateInternal. TherequestUpdatemethod is now identical to this method and should be used instead. -
#2103
15a8356d- Updates theexportsfield ofpackage.jsonfiles 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.
- A public
renderOptionsclass field now exists onLitElementand can be set/overridden to modify the options passed tolit-html. - Adds
static shadowRootOptionsfor customizing shadowRoot options. Rather than implementingcreateRenderRoot, this property can be set. For example, to create a closed shadowRoot using delegates focus:static shadowRootOptions = {mode: 'closed', delegatesFocus: true}. - Adds development mode, which can be enabled by setting the
developmentNode exports condition. See Development and production builds for more details.
- #1964
f43b811- Don't publish src/ to npm. - For efficiency, the
cssfunction now maintains a cache and will use a cached value if available when the same style text is requested. - Fixed reflecting a property when it is set in a setter of another property that is called because its attribute changed (#965).
- Fixed exceptions when parsing attributes from JSON (#722).
- Fixed issue with combining
static get propertieson an undefined superclass with@propertyon a subclass ([#890]lit/lit-element#890));
@lit/reactive-elementis a new package that factors out the base class that provides the reactive update lifecycle based on property/attribute changes toLitElement(what was previously calledUpdatingElement) into a separate package.LitElementnow extendsReactiveElementto addlit-htmlrendering via therender()callback. See ReactiveElement API for more details.UpdatingElementhas been renamed toReactiveElement.- The
updating-elementpackage has been renamed to@lit/reactive-element. - The
@internalPropertydecorator has been renamed to@state. - For consistency, renamed
_getUpdateCompletetogetUpdateComplete. - When a property declaration is
reflect: trueand itstoAttributefunction returnsundefinedthe attribute is now removed where previously it was left unchanged (#872). - 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
unhandledrejectionevent handler on window. - ReactiveElement's
renderRootis now created when the element'sconnectedCallbackis initially run. - Removed
requestUpdateInternal. TherequestUpdatemethod is now identical to this method and should be used instead. - The
initializemethod has been removed. This work is now done in the element constructor.
- Adds
static addInitializerfor adding a function which is called with the element instance when is created. This can be used, for example, to create decorators which hook into element lifecycle by creating a reactive controller (#1663). - Added ability to add a controller to an element. A controller can implement callbacks that tie into element lifecycle, including
connectedCallback,disconnectedCallback,willUpdate,update, andupdated. To ensure it has access to the element lifecycle, a controller should be added in the element's constructor. To add a controller to the element, calladdController(controller). - Added
removeController(controller)which can be used to remove a controller from aReactiveElement. - Added
willUpdate(changedProperties)lifecycle method to UpdatingElement. This is called before theupdatemethod and can be used to compute derived state needed for updating. This method is intended to be called during server side rendering and should not manipulate element DOM.
-
The
templateFactoryoption ofRenderOptionshas been removed. -
TemplateProcessorhas 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-rendermodule has been removed and is now part ofplatform-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.styleElementis 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@applyfeature. 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, usearray.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
Directivebase class anddirective()factory function are now exported from thelit-html/directive.jsmodule. -
NodeParthas been renamed toChildPart, along with other methods and variables that use the "Node" naming, likePartType.Nodewhich is nowPartType.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 indirective-helpers.jsto construct parts. -
The
eventContextrender option has been changed tohost. -
#2103
15a8356d- Updates theexportsfield ofpackage.jsonfiles 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.
- Added
renderBeforeto render options. If specified, content is rendered before the node given via render options, e.g.{renderBefore: node}. - Added development mode, which can be enabled by setting the
developmentNode exports condition. See Development and production builds for more details. - All usage of
instanceofhas been removed, making rendering more likely to work when multiple instances of the library interact. - Template processing is more robust to expressions in places other than text and attribute values.
rendernow returns theChildPartthat was created/updated byrender.- Added
AsyncDirective, which is aDirectivesubclass whosedisconnectedcallback 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 thesetConnectedAPI, and whosereconnectedcallback will be called when manually re-connected usingsetConnected. When implementingdisconnected, thereconnectedcallback should also be implemented to return the directive to a usable state. Note thatLitElementwill disconnect directives upon element disconnection, and re-connect directives upon element re-connection. See Async directives for more details. - Added
setConnected(isConnected: boolean)toChildPart; when called withfalse, thedisconnectedcallback 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 withtrue, any such directives'reconnectedcallback will be called prior to its nextupdate/rendercallbacks. Note thatLitElementwill call this method by default on the rendered part in itsconnectedCallbackanddisconnectedCallback. - Added the
static-htmlmodule, a statichtmltag function, aliteraltag function, andunsafeStatic(), 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. - Added
lit-html/directive-helpers.jsmodule with helpers for creating custom directives. See Custom directives for more details. - Rendering
null,undefined, or empty string in aChildPartnow has the same affect as renderingnothing: 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. - Nested directives whose parent returns
noChangeare now unchanged. This allows theguarddirective to guard directive values (#1519). - Added optional
creationScopetoRenderOptions, which controls the node from which the template is cloned from. - Added support for running with Trusted Types enforced.
-
#1922
8189f094- BindingnoChangeinto 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 usinguntil()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-partyAsyncDirectives (until,asyncAppend,asyncReplace) so that the directive (and any DOM associated with it) can be garbage collected before any promises they are awaiting resolve.