Skip to content

Commit 6180601

Browse files
committed
fix microsoft#146397. Clear container for html and plain text renderer.
1 parent 14d3a4b commit 6180601

File tree

1 file changed

+7
-0
lines changed
  • extensions/notebook-renderers/src

1 file changed

+7
-0
lines changed

extensions/notebook-renderers/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ interface IDisposable {
1111
dispose(): void;
1212
}
1313

14+
function clearContainer(container: HTMLElement) {
15+
while (container.firstChild) {
16+
container.removeChild(container.firstChild);
17+
}
18+
}
1419

1520

1621
function renderImage(outputInfo: OutputItem, element: HTMLElement): IDisposable {
@@ -61,6 +66,7 @@ const domEval = (container: Element) => {
6166
};
6267

6368
function renderHTML(outputInfo: OutputItem, container: HTMLElement): void {
69+
clearContainer(container);
6470
const htmlContent = outputInfo.text();
6571
const element = document.createElement('div');
6672
const trustedHtml = ttPolicy?.createHTML(htmlContent) ?? htmlContent;
@@ -149,6 +155,7 @@ function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boo
149155
}
150156

151157
function renderText(outputInfo: OutputItem, container: HTMLElement, ctx: RendererContext<void> & { readonly settings: { readonly lineLimit: number } }): void {
158+
clearContainer(container);
152159
const contentNode = document.createElement('div');
153160
contentNode.classList.add('output-plaintext');
154161
const text = outputInfo.text();

0 commit comments

Comments
 (0)