Skip to content

Commit

Permalink
fix(ilc): hard remove CSS link when an embedded application is unmounter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Malygin authored and Volodymyr Malyhin committed Sep 30, 2024
1 parent f6d3843 commit 4fa5731
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ilc/client/CssTrackedApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class CssTrackedApp {
return newInstance;
}

return new CssTrackedApp(newInstance, this.#cssLinkUri, this.#delayCssRemoval).getDecoratedApp();
return new CssTrackedApp(newInstance, this.#cssLinkUri, false).getDecoratedApp();
});
};

Expand Down
23 changes: 23 additions & 0 deletions ilc/client/CssTrackedApps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,29 @@ describe('CssTrackedApp', function () {
}),
);
});

it('should remove CSS link after createNew, mount, and unmount', async () => {
const returnValue = Math.random();
const appOnCreateNew = createOriginalAppFake(Promise.resolve(returnValue));
const originalApp = createOriginalAppFake(Promise.resolve(Math.random()));
originalApp.createNew = () => Promise.resolve(appOnCreateNew);

const cssLink = 'data:text/css,<style>div { border: 1px solid blue; }</style>';
const cssWrap = new CssTrackedApp(originalApp, cssLink, false).getDecoratedApp();

const newApp = await cssWrap.createNew();

await newApp.mount();

let link = document.querySelector(`link[href="${cssLink}"]`);
expect(link).to.not.be.null;
expect(link.getAttribute(CssTrackedApp.linkUsagesAttribute)).to.equal('1');

await newApp.unmount();

link = document.querySelector(`link[href="${cssLink}"]`);
expect(link).to.be.null;
});
});

it('should add counter to css on mount', async () => {
Expand Down

0 comments on commit 4fa5731

Please sign in to comment.