lottie-player
lottie-player copied to clipboard
Error when the script is re-added to the page.
Hi, I'm editing a site where user can select and preview predefined templates. The page works by previewing the template, not in an iframe, but in the page itself, via changing the HTML, including all the scripts that comes with the specific page.
The problem is that every time lottie-player is re-added, it triggers a JS error which makes other things in the script not working. It comes from the fact that lottie-player is added in customElements without verifying if the custom element already exist.
I could get past that by verifying if lottie-player exists in customElements before re-adding it, but I'm just also opening this issue, maybe you will fix it.
To replicate: https://jsfiddle.net/e9df4xz6/
Click on the button, an error appears:
Will look in to it @9brada6, cheers
I desperately need a solution for this as well.
This line is problematic as far as I can tell: https://github.com/LottieFiles/lottie-player/blob/0800352487ea64ef593daf04325036761d7009cb/src/lottie-player.ts#L106C1-L106C32
This line will cause the name "lottie-player" and class to be registered to the window.customElements object. This is normally fine ofcourse. But when that happens more then once it throws the error mentioned above. Unfortunately window.cusomElements just throws an error instead of overriding it, and there is no way to unregistering a name.
Please also see this tread and especially this comment I would say: https://github.com/WICG/webcomponents/issues/754#issuecomment-1369561215