lite-youtube icon indicating copy to clipboard operation
lite-youtube copied to clipboard

Update lite-youtube.ts

Open amoreaulemay opened this issue 2 years ago • 3 comments

Guards customElements from redefining 'lite-youtube' if it already exists.

amoreaulemay avatar Feb 08 '23 11:02 amoreaulemay

Humm, the double-stamp workaround. This seems to me (now, in 2023) unnecessary unless you're working with a build that is not properly de-duplicating the module. Is there a specific case you're trying to work around?

justinribeiro avatar Feb 08 '23 17:02 justinribeiro

Yes, we use a component library that bundles every component as its own module. We have a few variants of these components on one page but because they are self contained they redeclare the component.

As a general rule, it's also a good guard to check if the component is already defined.

amoreaulemay avatar Feb 08 '23 17:02 amoreaulemay

Yes, we use a component library that bundles every component as its own module. We have a few variants of these components on one page but because they are self contained they redeclare the component.

Sigh, that is not great pattern for so many reasons.

As a general rule, it's also a good guard to check if the component is already defined.

Nahhh, it's a workaround for bad build behaviors and poor dependency management. We never had a rule in the wc gold standard for it, it's always been considered a dirty fix, and you don't find it in most of the heavy-use web components. Case in point: https://github.com/google/model-viewer/blob/1811263f6cf0bb7b1ab64f67d3002101eafd997d/packages/model-viewer/src/model-viewer.ts#L39

Let me give it some though before I cut a point release this week.

justinribeiro avatar Feb 08 '23 17:02 justinribeiro