Paul Lewis | 9950e18 | 2019-12-16 16:06:07 | [diff] [blame^] | 1 | // 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 | |
| 5 | /** |
| 6 | * @param {!Node} node |
| 7 | * @param {string} cssFile |
| 8 | * @suppressGlobalPropertiesCheck |
| 9 | */ |
| 10 | export function appendStyle(node, cssFile) { |
| 11 | const content = Root.Runtime.cachedResources[cssFile] || ''; |
| 12 | if (!content) { |
| 13 | console.error(cssFile + ' not preloaded. Check module.json'); |
| 14 | } |
| 15 | let styleElement = createElement('style'); |
| 16 | styleElement.textContent = content; |
| 17 | node.appendChild(styleElement); |
| 18 | |
| 19 | const themeStyleSheet = UI.themeSupport.themeStyleSheet(cssFile, content); |
| 20 | if (themeStyleSheet) { |
| 21 | styleElement = createElement('style'); |
| 22 | styleElement.textContent = themeStyleSheet + '\n' + Root.Runtime.resolveSourceURL(cssFile + '.theme'); |
| 23 | node.appendChild(styleElement); |
| 24 | } |
| 25 | } |