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

Idea: offer multiple ways for injecting widgets, like an HTMLElement subclass or an element-name? #15

Open
JulianCataldo opened this issue Oct 25, 2024 · 1 comment

Comments

@JulianCataldo
Copy link
Contributor

JulianCataldo commented Oct 25, 2024

This lib should be agnostic. Actually a lit html (TemplateResult<1>) is preferred because it makes it easier to deal with accessibility issues with vendor custom elements that associate in the same form, as soon as they share the same DOM sub-tree.

However, passing a "true", well scoped custom element should be offered as a way to provide to the JSFE API.

  • When using createRenderRoot with light dom with a LitElement.
  • When using a vanilla HTMLElement with a this.innerHTML.
  • When the user is aware of cross DOM-tree concerns and know how to deal with them (FACE, custom internals and other specs I'm not familiar with yet).

That raise a couple of issues, especially on the initial props. definition phase. With a template factory function, it's simple to type and to require props.
But with the custom element, it's up to the user to enforce props. to be defined on first init with defensive assertion and a template fallback.

Also, is it preferable to use a subclass of an HTMLElement or doing document.createElement('user-provided-element')?

@JulianCataldo JulianCataldo changed the title Idea: offer multiple way of injecting widgets, like an HTMLElement subclass or an element-name? Idea: offer multiple ways for injecting widgets, like an HTMLElement subclass or an element-name? Oct 25, 2024
@JulianCataldo
Copy link
Contributor Author

I think using slots is the path forward. Currently experimenting with them, and it will make the library framework agnostic regarding widget creation.
That would require some kind of external store, though. Probably backed by TC39 signals.

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

1 participant