Migrates internal refs of ui/ to esm

Please note: ESLint and Closure have different opinions on the
necessity of imports, thus // eslint-disable-line no-unused-vars
was added to imports used only for Closure types.

Bug: 1006759
Change-Id: Idd32e12d23a636f1e0fdcb90742e4b706e3cef77
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1967134
Commit-Queue: Paul Lewis <[email protected]>
Reviewed-by: Tim van der Lippe <[email protected]>
diff --git a/front_end/ui/utils/append-style.js b/front_end/ui/utils/append-style.js
new file mode 100644
index 0000000..385bee9
--- /dev/null
+++ b/front_end/ui/utils/append-style.js
@@ -0,0 +1,25 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @param {!Node} node
+ * @param {string} cssFile
+ * @suppressGlobalPropertiesCheck
+ */
+export function appendStyle(node, cssFile) {
+  const content = Root.Runtime.cachedResources[cssFile] || '';
+  if (!content) {
+    console.error(cssFile + ' not preloaded. Check module.json');
+  }
+  let styleElement = createElement('style');
+  styleElement.textContent = content;
+  node.appendChild(styleElement);
+
+  const themeStyleSheet = UI.themeSupport.themeStyleSheet(cssFile, content);
+  if (themeStyleSheet) {
+    styleElement = createElement('style');
+    styleElement.textContent = themeStyleSheet + '\n' + Root.Runtime.resolveSourceURL(cssFile + '.theme');
+    node.appendChild(styleElement);
+  }
+}