Why are Lit elements' `connectedCallback` always called twice?

I noticed this a while back, but am only addressing it now. If I create a custom element using Lit, write a Component mapping, and add that component to the UI, the connectedCallback method is always called twice. This is not normal Lit behavior. Anyone know why? You can reproduce this in the starter app by creating a simple Lit element and adding it to the UI.

I think this is due to how Vaadin router works. Flow will first create the elements into some container div, and later router picks them up and moves them into its own container. Moving an element in the DOM causes it to be disconnected and then connected again.

if you’re looking for a method that’s called only once in the beginning, constructor might be useful.

But attributes haven’t been mapped to properties there yet.

@cheerful-baboon I checked the code and you are absolutely right. Thank you.