Which package(s) are affected?
Lit Core (lit / lit-html / lit-element / reactive-element)
Description
When an element is imperatively created and performUpdate() is called on it before adding it to the DOM, an exception is generated and the element does not render when it is added to the DOM.
This error occurs because the element's renderRoot is created in connectedCallback. This issue could be fixed by creating the render root on the first update.
Reproduction
https://lit.dev/playground/#gist=d5f782efaf4758e2d17f68a77216c38c
const e = document.createElement('my-element');
e.performUpdate();
// Uncaught TypeError: The container to render into may not be undefined
Workaround
performUpdate() {
if (this.renderRoot === undefined) {
this.renderRoot = this.createRenderRoot();
}
super.performUpdate();
}
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
2.x, 3.x
Browser/OS/Node environment
All