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

Add "extend" option to enable ability to use own custom element class #42

Open
patricknelson opened this issue Dec 13, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@patricknelson
Copy link
Owner

patricknelson commented Dec 13, 2023

Describe the problem

Users cannot easily add their own integration or lifecycle hooks into the actual custom element itself that svelte-retag creates.

Relates to #13.

Describe the proposed solution

Add ability for the developer to pass their own class into a new extend option. This class would extend the svelte-retag managed constructor passed to it so that they could add their own lifecycle hooks. When building this, we should attempt parity with how Svelte also implements this. Therefore, this would ideally match the functionality already documented here as much as possible: https://svelte.dev/docs/custom-elements-api#component-options

Example usage modified from sveltejs/svelte#3091 (comment)

svelteRetag({
  component: HelloWorld,
  tagname: 'hello-world',
  extend: (customElementConstructor) => {
    return class extends customElementConstructor {
      constructor() {
        super();
        this.attachedInternals = this.attachInternals();
      }
    };
  }
});

Alternatives considered

None.

Importance

nice to have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant