blob: 11ead59a36b591419da588f7525fd5ac118c199a [file] [log] [blame]
Paul Lewis9950e182019-12-16 16:06:071// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Tim van der Lippeee97fa32020-04-23 15:20:565// @ts-nocheck
6// TODO(crbug.com/1011811): Enable TypeScript compiler checks
7
Paul Lewis9950e182019-12-16 16:06:078/**
9 * @param {!Node} node
10 * @param {string} cssFile
11 * @suppressGlobalPropertiesCheck
12 */
13export function appendStyle(node, cssFile) {
Tim van der Lippe6d51bf02020-03-18 12:15:1414 const content = self.Runtime.cachedResources[cssFile] || '';
Paul Lewis9950e182019-12-16 16:06:0715 if (!content) {
16 console.error(cssFile + ' not preloaded. Check module.json');
17 }
18 let styleElement = createElement('style');
19 styleElement.textContent = content;
20 node.appendChild(styleElement);
21
Paul Lewis93d8e2c2020-01-24 16:34:5522 const themeStyleSheet = self.UI.themeSupport.themeStyleSheet(cssFile, content);
Paul Lewis9950e182019-12-16 16:06:0723 if (themeStyleSheet) {
24 styleElement = createElement('style');
25 styleElement.textContent = themeStyleSheet + '\n' + Root.Runtime.resolveSourceURL(cssFile + '.theme');
26 node.appendChild(styleElement);
27 }
28}