MCPcopy Index your code
hub / github.com/microsoft/rushstack / registerStyles

Function registerStyles

src/index.ts:220–240  ·  view source on GitHub ↗

* Registers a set of style text. If it is registered too early, we will register it when the * window.load event is fired. * @param {ThemableArray} styleArray Array of IThemingInstruction objects to register. * @param {IStyleRecord} styleRecord May specify a style Element to update.

(styleArray: ThemableArray, styleRecord?: IStyleRecord)

Source from the content-addressed store, hash-verified

218 * @param {IStyleRecord} styleRecord May specify a style Element to update.
219 */
220function registerStyles(styleArray: ThemableArray, styleRecord?: IStyleRecord): void {
221 const head: HTMLHeadElement = document.getElementsByTagName('head')[0];
222 const styleElement: HTMLStyleElement = document.createElement('style');
223
224 styleElement.type = 'text/css';
225 styleElement.appendChild(document.createTextNode(resolveThemableArray(styleArray)));
226
227 if (styleRecord) {
228 head.replaceChild(styleElement, styleRecord.styleElement);
229 styleRecord.styleElement = styleElement;
230 } else {
231 head.appendChild(styleElement);
232 }
233
234 if (!styleRecord) {
235 _themeState.registeredStyles.push({
236 styleElement: styleElement,
237 themableStyle: styleArray
238 });
239 }
240}
241
242/**
243 * Registers a set of style text, for IE 9 and below, which has a ~30 style element limit so we need

Callers 1

applyThemableStylesFunction · 0.85

Calls 1

resolveThemableArrayFunction · 0.85

Tested by

no test coverage detected