fix: <webview> not working with Trusted Types (#27465)

Co-authored-by: Milan Burda <milan.burda@gmail.com>
This commit is contained in:
trop[bot]
2021-01-25 11:47:33 -08:00
committed by GitHub
parent 0ead47ffea
commit 2e98e11364
3 changed files with 22 additions and 4 deletions

View File

@@ -41,7 +41,9 @@ export class WebViewImpl {
// Create internal iframe element.
this.internalElement = this.createInternalElement();
const shadowRoot = this.webviewNode.attachShadow({ mode: 'open' });
shadowRoot.innerHTML = '<!DOCTYPE html><style type="text/css">:host { display: flex; }</style>';
const style = shadowRoot.ownerDocument!.createElement('style');
style.textContent = ':host { display: flex; }';
shadowRoot.appendChild(style);
this.setupWebViewAttributes();
this.viewInstanceId = getNextId();
shadowRoot.appendChild(this.internalElement);