Repository navigation
SCAL-349561 Fixed Render a new iframe when replaceExistingPreRender is true - #772
shivam-kumar-ts wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the ability to discard and replace an existing pre-rendered embed when replaceExistingPreRender is set to true. It introduces a discard method in PreRenderController to destroy and clear the wrapper and child elements, and a discardExistingPreRender helper in TsEmbed to clean up event listeners and reset state. Corresponding unit tests have been added to verify that the old iframe is disconnected and a new one is successfully rendered. There are no review comments to address, and the changes look solid.
commit: |
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to discard and replace an existing pre-rendered embed instance when replaceExistingPreRender is enabled. It adds a discard method to PreRenderController to clean up elements and implements discardExistingPreRender in TsEmbed to unsubscribe the previous owner and reset the iframe. The feedback suggests a critical improvement: ensuring that the previousOwner's iFrame and isRendered properties are also reset to prevent memory leaks or errors if the old instance is accessed later. Additionally, the reviewer recommends updating the unit tests to assert that this state cleanup is performed correctly.
5e0dce0 to
aa2bca6
Compare
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to discard and replace an existing pre-rendered iframe when replaceExistingPreRender is enabled, adding cleanup logic in both TsEmbed and PreRenderController along with corresponding unit tests. The review feedback correctly identifies an opportunity to prevent memory leaks by ensuring event listeners are cleaned up even when the previous owner is the current instance, and suggests updating setIframeElement to accept undefined to prevent TypeScript compilation errors.
761a9fa to
aa2bca6
Compare
The problem
A pre-render is a hidden iframe that loads a Liveboard in the background, so it opens instantly later.
The app pre-renders Liveboard A. Later it says: "throw that away and pre-render Liveboard B instead". That's what
preRender(false, true)means; the secondtrueisreplaceExistingPreRender.But the hidden frame kept showing A.
What I changed
In
preRender(), when a pre-render already exists andreplaceExistingPreRenderistrue, the SDK now cleans up first with a new step,discardExistingPreRender():preRenderController.discard()), and forgets about them.this.iFrame = undefined) and marks itself as not rendered yet.Then the normal render runs. It finds no iframe, so it creates a brand-new one from B's config, and B loads.