Repository navigation
[utils] Improve mergeSlotProps performance - #48002
Conversation
Netlify deploy previewhttps://deploy-preview-48002--material-ui.netlify.app/ Bundle size report
|
c643f65 to
d72a7f3
Compare
codeCraft-Ritik
left a comment
There was a problem hiding this comment.
Great contribution! The implementation is clean and integrates well with the existing codebase
|
Make sure to mark it as cherry pick if it's for v7 |
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
|
@claude review |
PR reviewNothing here is merge-blocking. I traced every rewritten branch against its base version and the three refactors ( Tests (2)1. 🟠 The new empty-style test passes even if the whole style-merge block is deletedLocation: it('preserves an empty style prop when all provided style props are empty objects', () => {
const merged = mergeSlotProps({
additionalProps: { style: {} },
externalForwardedProps: { style: {} },
externalSlotProps: { style: {} },
});
expect(merged.props).to.haveOwnProperty('style');
expect(merged.props.style).to.deep.equal({});In this scenario the style-merge block never assigns Failure scenario: Delete the entire Fix: Assert what the block actually does in this case — that 2. 🟠 No test merges styles through the
|
ZeeshanTamboli
left a comment
There was a problem hiding this comment.
Made some more improvements. Looks good to be merged now.
Borrowed some ideas from Base UI:
charCodeAtchecks instead of regexesObject.keys().filter().forEach()with for loops to remove extra array allocationsstyleprop is not supplied (usingsxinstead ofstyle) remove unnecessary spreads andObject.keysinmergeSlotPropsomitEventHandlersin Material UI (unused duplicate), a canonical version is in utilsThe
+0.05%gzip size increase is probably mostly from replacing the regex withcharCodeAtbut worth it as it could be 20-30% faster on slower devices: mui/base-ui#456