Major Changes
@lit/reactive-element
is 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.LitElement
now extendsReactiveElement
to addlit-html
rendering via therender()
callback. See ReactiveElement API for more details.UpdatingElement
has been renamed toReactiveElement
.- The
updating-element
package has been renamed to@lit/reactive-element
. - The
@internalProperty
decorator has been renamed to@state
. - For consistency, renamed
_getUpdateComplete
togetUpdateComplete
. - When a property declaration is
reflect: true
and itstoAttribute
function returnsundefined
the 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
unhandledrejection
event handler on window. - ReactiveElement's
renderRoot
is now created when the element'sconnectedCallback
is initially run. - Removed
requestUpdateInternal
. TherequestUpdate
method is now identical to this method and should be used instead. - The
initialize
method has been removed. This work is now done in the element constructor.
Minor Changes
- Adds
static addInitializer
for 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
hostConnected
,hostDisconnected
,hostUpdate
, andhostUpdated
. 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 theupdate
method 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.