WebUI: Fix _LIT_ICONS_TEMPLATE in html_to_wrapper() to not overwrite.

Previously it was using a call like `render(template, document.head);`
which accidentally cleared other nodes in <head>.

Fixed: 336453385
Change-Id: I95585c7c93244674940a0ba63fac9d4137aabc25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5478728
Auto-Submit: Demetrios Papadopoulos <[email protected]>
Reviewed-by: Rebekah Potter <[email protected]>
Commit-Queue: Rebekah Potter <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1291515}
diff --git a/tools/polymer/html_to_wrapper.py b/tools/polymer/html_to_wrapper.py
index 05eaa9b..062ef045 100644
--- a/tools/polymer/html_to_wrapper.py
+++ b/tools/polymer/html_to_wrapper.py
@@ -63,10 +63,14 @@
 
 # Template for Lit icon HTML files.
 _LIT_ICONS_TEMPLATE = """import '%(scheme)s//resources/cr_elements/cr_icon/cr_iconset.js';
-import {html, render} from '%(scheme)s//resources/lit/v3_0/lit.rollup.js';
+import {getTrustedHTML} from '%(scheme)s//resources/js/static_types.js';
 
-const iconsetHtml = html`%(content)s`;
-render(iconsetHtml, document.head);
+const div = document.createElement('div');
+div.innerHTML = getTrustedHTML`%(content)s`;
+const iconsets = div.querySelectorAll('cr-iconset');
+for (const iconset of iconsets) {
+  document.head.appendChild(iconset);
+}
 """
 
 # Tokens used to detect whether the underlying custom element is based on