Open Hyzual opened 1 month ago
Is it the use case where you import files that define elements more than once on the same page?
Yes, we have "internal libraries" that define elements, and they can end up being used in several bundled JS files that are loaded on the same page.
Hi, again thank you for sharing with us and maintaining hybrids, it's been a great help for us!
We are in a situation where we can sometimes load the code to define the same custom element (for example:
tuleap-lazybox-dropdown
) twice on the same page. Since the element is defined with thedefine()
function from hybrids, when this happens, it raises the following error:The error is definitely useful, but in our case the element is really the same one, so it is okay to just "not re-define it". We can use the following code to achieve that:
Do you think, as a feature request, we could maybe use another function or option from hybrids to have this behavior, to define an element unless its tag name is already in the customElements registry ? Maybe something like
define.optional({ <element definition object...> })
. What do you think about it ?