Skip to content

Commit 0a2707b

Browse files
committed
fix microsoft#146397. Clear container for html and plain text renderer.
1 parent 5cc4bc6 commit 0a2707b

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
@@ -10,6 +10,11 @@ interface IDisposable {
1010
dispose(): void;
1111
}
1212

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

1419

1520
function renderImage(outputInfo: OutputItem, element: HTMLElement): IDisposable {
@@ -60,6 +65,7 @@ const domEval = (container: Element) => {
6065
};
6166

6267
function renderHTML(outputInfo: OutputItem, container: HTMLElement): void {
68+
clearContainer(container);
6369
const htmlContent = outputInfo.text();
6470
const element = document.createElement('div');
6571
const trustedHtml = ttPolicy?.createHTML(htmlContent) ?? htmlContent;
@@ -150,6 +156,7 @@ function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boo
150156
}
151157

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

0 commit comments

Comments
 (0)