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

Support slots in IIFE (non-deferred) in light DOM #7

Closed
patricknelson opened this issue Jun 8, 2023 · 1 comment
Closed

Support slots in IIFE (non-deferred) in light DOM #7

patricknelson opened this issue Jun 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@patricknelson
Copy link
Owner

Describe the problem

Currently slots are not properly rendered when the the entrypoint defining the custom elements and associated Svelte components run prior to the initial parsing of the DOM. As the parser processes HTML, it will encounter the custom element and immediately as soon as it is encountered, it will execute the constructor() and connectedCallback() functions even before it has reached the interior containing the slots.

Describe the proposed solution

Use MutationObserver to watch for changes and re-render the component once slots are encountered. This is how shadow DOM slots are already being addressed.

Alternatives considered

Await tick() (e.g. setTimeout() with 0ms delay) to wait until thread is no longer blocking, but this is super hacky and also causes a flicker. The requestAnimationFrame() would be similarly as hacky if not induce a longer delay.

Note: Very important to me since our components are compiled as IIFE's (see rollup docs) and included early in the page load (i.e. in the <head>) and thus this currently renders slots unusable.

Importance

i cannot use svelte-retag without it

@patricknelson
Copy link
Owner Author

Completed in #8

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