fix ssr for sl-alert and scrollend-polyfill #2359
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello Shoelace team!
We are currently in the works of creating an SSR compatible version of our own fork of Shoelace, Synergy. It works pretty well, but we stumbled upon two issues, preventing it to work in Angular SSR environments:
<sl-alert>
component does automatically create the toast stack when imported, leading to errors in SSR environments becausedocument.createElement
is always fired.scrollend-polyfill
directly checks for'scrollend' in window
when it is included. This prevents the use of<sl-tab-group>
in SSR environments.We already patched this in our alert and polyfill implementation, but wanted to mirror this back for everyone that might be interested.
That said, as we have not tested SSR in Vanilla environments, but only in framework based ones (e.g. https://github.com/synergy-design-system/ssr-demos/tree/main/packages/angular gives a good demo with our findings).
The changes are really simple ones and, for
<sl-alert>
, also have the benefit that the stack is only created when thetoast
method is called at all.Hope this may prove helpful for the community, also regarding the discussion in #1641.
We would also loved to have provided this for Webawesome, but as I see, you seem to have completely got rid of
<sl-alert>
in favor of<wa-callout>
which comes without the original toast stack functionality. Just out of curiosity, what where the reasons for this change?Closes #2358