-
Notifications
You must be signed in to change notification settings - Fork 287
Open
Description
lite-youtube-embed/src/lite-yt-embed.js
Line 239 in 1b88628
| customElements.define('lite-youtube', LiteYTEmbed); |
Adding the script more than once results in browser console errors
youtube/:7699 Uncaught NotSupportedError: Failed to execute 'define' on 'CustomElementRegistry': the name "lite-youtube" has already been used with this registry
The component JS always runs customElements.define() instead of checking, if the component is already defined, using for instance.
if (!customElements.get('lite-youtube')) {
customElements.define('lite-youtube', LiteYTEmbed);
} else {
// do nothing or print a nice warning
}While it is better to instantiate this right away correctly, people might attempt to add the script twice per site or even once per embed if used multiple times per page. Checking if it's already defined would silence the browser console.
Metadata
Metadata
Assignees
Labels
No labels