Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (staticSheet) {
return staticSheet
}
const contextSheetOptions = this.context[ns.sheetOptions]
const styles = getStyles(stylesOrCreator, theme)
staticSheet = this.jss.createStyleSheet(styles, {
...sheetOptions,
...contextSheetOptions,
meta: `${displayName}, ${isThemingEnabled ? 'Themed' : 'Unthemed'}, Static`,
classNamePrefix: this.classNamePrefix
})
this.manager.add(theme, staticSheet)
// $FlowFixMe Cannot add random fields to instance of class StyleSheet
staticSheet[dynamicStylesNs] = getDynamicStyles(styles)
return staticSheet
}
.add('JSS naked', () => {
const sheetsRegistry = new SheetsRegistry();
const staticStyles = cssObject;
const dynamicStyles = getDynamicStyles(staticStyles);
const staticSheet = jss.createStyleSheet(staticStyles);
staticSheet.attach({
link: false,
});
sheetsRegistry.add(staticSheet);
if (dynamicStyles) {
const dynamicSheet = jss.createStyleSheet(dynamicStyles, {
link: true,
});
dynamicSheet.update({}).attach();
sheetsRegistry.add(dynamicSheet);
}
ReactDOMServer.renderToString(
link: false,
...options,
});
staticSheet.attach();
if (stylesOptions.sheetsCache) {
multiKeyStore.set(stylesOptions.sheetsCache, stylesCreator, theme, staticSheet);
}
}
if (sheetsRegistry) {
sheetsRegistry.add(staticSheet);
}
sheetManager.staticSheet = staticSheet;
sheetManager.dynamicStyles = getDynamicStyles(styles);
}
if (sheetManager.dynamicStyles) {
const dynamicSheet = stylesOptions.jss.createStyleSheet(sheetManager.dynamicStyles, {
link: true,
...options,
});
dynamicSheet.update(props).attach();
state.dynamicSheet = dynamicSheet;
state.classes = mergeClasses({
baseClasses: sheetManager.staticSheet.classes,
newClasses: dynamicSheet.classes,
});
export const createStyleSheet = (options: Options) => {
if (options.context.disableStylesGeneration) {
return undefined
}
const manager = getManager(options.context, options.index)
const existingSheet = manager.get(options.theme)
if (existingSheet) {
return existingSheet
}
const jss = options.context.jss || defaultJss
const styles = getStyles(options)
const dynamicStyles = getDynamicStyles(styles)
const sheet = jss.createStyleSheet(styles, getSheetOptions(options, dynamicStyles !== null))
addMeta(sheet, {
dynamicStyles,
styles,
dynamicRuleCounter: 0
})
manager.add(options.theme, sheet)
return sheet
}