fix #146397. Clear container for html and plain text renderer.

This commit is contained in:
rebornix 2022-03-31 14:00:18 -07:00
parent 5cc4bc671b
commit 0a2707bbf0
No known key found for this signature in database
GPG key ID: 181FC90D15393C20

View file

@ -10,6 +10,11 @@ interface IDisposable {
dispose(): void;
}
function clearContainer(container: HTMLElement) {
while (container.firstChild) {
container.removeChild(container.firstChild);
}
}
function renderImage(outputInfo: OutputItem, element: HTMLElement): IDisposable {
@ -60,6 +65,7 @@ const domEval = (container: Element) => {
};
function renderHTML(outputInfo: OutputItem, container: HTMLElement): void {
clearContainer(container);
const htmlContent = outputInfo.text();
const element = document.createElement('div');
const trustedHtml = ttPolicy?.createHTML(htmlContent) ?? htmlContent;
@ -150,6 +156,7 @@ function renderStream(outputInfo: OutputItem, container: HTMLElement, error: boo
}
function renderText(outputInfo: OutputItem, container: HTMLElement, ctx: RendererContext<void> & { readonly settings: { readonly lineLimit: number } }): void {
clearContainer(container);
const contentNode = document.createElement('div');
contentNode.classList.add('output-plaintext');
const text = outputInfo.text();