Skip to content

Commit

Permalink
add and adopt trusted types apply util, #106396
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Oct 5, 2020
1 parent 8140033 commit 5d9b22c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export function clearNode(node: HTMLElement): void {
}
}

export function trustedInnerHTML(node: Element, value: TrustedHTML): void {
// this is a workaround for innerHTML not allowing for "asymetric" accessors
// see https://github.com/microsoft/vscode/issues/106396#issuecomment-692625393
// and https://github.com/microsoft/TypeScript/issues/30024
node.innerHTML = value as unknown as string;
}

export function isInDOM(node: Node | null): boolean {
while (node) {
if (node === document.body) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ class CodeCellDragImageRenderer {
return null;
}

editorContainer.innerHTML = richEditorText as unknown as string;
DOM.trustedInnerHTML(editorContainer, richEditorText);

return dragImageContainer;
}
Expand Down

0 comments on commit 5d9b22c

Please sign in to comment.