From 12f5d969d557a952bd047b4125990af006bc7de5 Mon Sep 17 00:00:00 2001 From: D V Date: Wed, 20 Sep 2023 14:53:22 +0530 Subject: [PATCH] update Typography color prop script and test --- packages/mui-material/src/Typography/Typography.test.js | 9 +++++++++ packages/mui-system/src/style.js | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/mui-material/src/Typography/Typography.test.js b/packages/mui-material/src/Typography/Typography.test.js index e6877e3339bb57..0144dbd0f2b9f4 100644 --- a/packages/mui-material/src/Typography/Typography.test.js +++ b/packages/mui-material/src/Typography/Typography.test.js @@ -122,4 +122,13 @@ describe('', () => { marginBottom: '16px', }); }); + + it('should check for invalid color value', () => { + const { container, debug } = render( + + Hello + , + ); + debug(container); + }); }); diff --git a/packages/mui-system/src/style.js b/packages/mui-system/src/style.js index 2767e7e306623a..144b59ae4dfe1d 100644 --- a/packages/mui-system/src/style.js +++ b/packages/mui-system/src/style.js @@ -39,6 +39,14 @@ export function getStyleValue(themeMapping, transform, propValueFinal, userValue value = transform(value, userValue, themeMapping); } + if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') { + // Log an error in development mode + if (process.env.NODE_ENV !== 'production') { + console.error(`Invalid value "${value}" for property "${userValue}"`); + } + value = userValue; + } + return value; }