4

I have been using as lit-html in my own custom web-component library. I have third party webcompobent :

html`<lottie-player src=${state.url}  background="transparent"  speed="1"  style="width: 100%; height: 100%;"  loop  autoplay></lottie-player>`

This third party components do not updates itself whenever src attribute is changed on it. I understand, they have not designed it as such.

Is there a way to force lit-html to re-render this, as when I chnage the state.url, instead of deleting old node and creating new one, lit-html keep the same node intact and changes only its attribute.

If there a way to force re-render for this specific template each time ?

Anurag Vohra
  • 1,781
  • 12
  • 28

1 Answers1

0

Ok, so I solved this issue by :

let b = `<lottie-player src=${state.url}  background="transparent"  speed="1"  style="width: 100%; height: 100%;"  loop  autoplay></lottie-player>`;
t = html`${unsafeHTML(b)}`;

Concept: B is a string using plain template string. Then then use unsafeHTML directive to create a re-render it!

If any one has any better solution, will be glad to read it too.

Anurag Vohra
  • 1,781
  • 12
  • 28