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

chore: add comments about new updates to CssTrackedApp #620

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ilc/client/CssTrackedApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class CssTrackedApp {
#originalApp;
#cssLinkUri;
#delayCssRemoval;
// used to prevent removing CSS immediately after unmounting
#isRouteChanged = false;
#routeChangeListener;

Expand All @@ -22,8 +23,11 @@ export class CssTrackedApp {
this.#cssLinkUri = cssLink;
this.#delayCssRemoval = delayCssRemoval;

// add route change listener for embedded apps
if (!delayCssRemoval) {
// While CSS for an application rendered by another application is not always immediately necessary upon unmount, there is a non-trivial case to consider:
// - When the route changes and a spinner is enabled in the registry, the root application is unmounted and destroyed.
// - ILC then shows a copy of the previously rendered DOM node.
// - Which leads to a situation where both the root and inner applications unmount synchronously. Despite being unmounted, their styles are still required until the route transition is complete.
this.#addRouteChangeListener();
}
}
Expand Down Expand Up @@ -128,6 +132,7 @@ export class CssTrackedApp {
}

#shouldDelayRemoval() {
// If the route is changing, we should delay CSS removal to prevent visual glitches.
return this.#delayCssRemoval || this.#isRouteChanged;
}

Expand Down
Loading