Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when the script is re-added to the page. #218

Open
9brada6 opened this issue Jun 28, 2023 · 4 comments
Open

Error when the script is re-added to the page. #218

9brada6 opened this issue Jun 28, 2023 · 4 comments

Comments

@9brada6
Copy link

9brada6 commented Jun 28, 2023

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:
image

@samuelOsborne
Copy link
Member

Will look in to it @9brada6, cheers

@Patrick-clone
Copy link

I desperately need a solution for this as well.

@Patrick-clone
Copy link

Patrick-clone commented Aug 25, 2023

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.

@Patrick-clone
Copy link

Please also see this tread and especially this comment I would say:
WICG/webcomponents#754 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants