[internal] mergeSlotProps improvements#48002
Open
mj12albert wants to merge 3 commits intomui:masterfrom
Open
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
silviuaavram
approved these changes
Mar 17, 2026
| ...defaultSlotPropsValue, | ||
| ...externalSlotPropsValue, | ||
| ...handlers, | ||
| ...(!!className && { className }), |
Member
There was a problem hiding this comment.
is this part better perf wise? if so, the className line above could also be added in the same way, since it's pretty much the same kind of change
| ...defaultSlotProps, | ||
| ...externalSlotProps, | ||
| ...handlers, | ||
| ...(!!className && { className }), |
| ...externalForwardedProps?.style, | ||
| ...externalSlotProps?.style, | ||
| }; | ||
| if (Object.keys(mergedStyle).length > 0) { |
Member
There was a problem hiding this comment.
if it's not true, we won't need to compute mergedStyle, right?
| ...externalForwardedProps?.style, | ||
| ...externalSlotProps?.style, | ||
| }; | ||
| if (Object.keys(mergedStyle).length > 0) { |
Member
|
Make sure to mark it as cherry pick if it's for v7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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