Skip to content

Commit

Permalink
[styles] Improve the dangerouslyUseGlobalCSS story (#12389)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Aug 2, 2018
1 parent b9c4c23 commit 2e6a6dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions packages/material-ui/src/styles/createGenerateClassName.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ export default function createGenerateClassName(options = {}) {

// Code branch the whole block at the expense of more code.
if (dangerouslyUseGlobalCSS) {
if (styleSheet && styleSheet.options.classNamePrefix) {
const prefix = safePrefix(styleSheet.options.classNamePrefix);

if (prefix.match(/^Mui/)) {
return `${prefix}-${rule.key}`;
if (styleSheet) {
if (styleSheet.options.name) {
return `${styleSheet.options.name}-${rule.key}`;
}

if (process.env.NODE_ENV !== 'production') {
if (styleSheet.options.classNamePrefix && process.env.NODE_ENV !== 'production') {
const prefix = safePrefix(styleSheet.options.classNamePrefix);
return `${prefix}-${rule.key}-${ruleCounter}`;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ describe('createGenerateClassName', () => {
},
{
options: {
classNamePrefix: 'MuiButton',
name: 'Button',
classNamePrefix: 'Button2',
jss: {},
},
},
),
'MuiButton-root',
'Button-root',
);
assert.strictEqual(
generateClassName(
Expand Down

0 comments on commit 2e6a6dc

Please sign in to comment.