Skip to content

customElements.whenDefined() not working for custom elements already defined before Polyfill is loaded #21

@mbehzad

Description

@mbehzad

Hi,
Image this scenario where there are a lot of custom elements and only a small part of them would extend build in elements, Safari would support the first ones but need the Polyfill for the build in extenders. I would prefer to lazyload the Polyfill only when needed and define only the CEs relaying on it after the Polyfill is loaded but the other ones define right away.

The problem is that to my understanding, for example, customElements.whenDefined is overridden and will only know about CEs that are defined after that point.

I could open a PR where the copy of the original customElements.whenDefined is kept and i.e. used as
return Promise.any([_defined.get(name).$, _originalWhenDefined(name)]);.

Does this make sense? is there anything else that could break? or supporting loading the pollyfill later for whenDefined brings the expectation that it also works with other APIs and that creates more confusion for the users?

cheers
Mehran

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions