Skip to content

Commit

Permalink
[system] Fix composeClasses v6 behavior change (#43537)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 3, 2024
1 parent f1d5fff commit 7a60e40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/mui-utils/src/composeClasses/composeClasses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('composeClasses', () => {
undefined,
),
).to.deep.equal({
root: 'MuiTest-root MuiTest-standard ',
slot: 'MuiTest-slot ',
root: 'MuiTest-root MuiTest-standard',
slot: 'MuiTest-slot',
});
});

Expand All @@ -32,8 +32,8 @@ describe('composeClasses', () => {
},
),
).to.deep.equal({
root: 'MuiTest-root MuiTest-standard standardOverride ',
slot: 'MuiTest-slot slotOverride ',
root: 'MuiTest-root MuiTest-standard standardOverride',
slot: 'MuiTest-slot slotOverride',
});
});

Expand All @@ -51,8 +51,8 @@ describe('composeClasses', () => {
},
),
).to.deep.equal({
root: 'MuiTest-root MuiTest-standard standardOverride ',
slot: 'MuiTest-slot slotOverride ',
root: 'MuiTest-root MuiTest-standard standardOverride',
slot: 'MuiTest-slot slotOverride',
});
});
});
6 changes: 4 additions & 2 deletions packages/mui-utils/src/composeClasses/composeClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ export default function composeClasses<ClassKey extends string>(
for (const slotName in slots) {
const slot = slots[slotName];
let buffer = '';
let start = true;

for (let i = 0; i < slot.length; i += 1) {
const value = slot[i];
if (value) {
buffer += getUtilityClass(value) + ' ';
buffer += (start === true ? '' : ' ') + getUtilityClass(value);
start = false;

if (classes && classes[value]) {
buffer += classes[value] + ' ';
buffer += ' ' + classes[value];
}
}
}
Expand Down

0 comments on commit 7a60e40

Please sign in to comment.