Skip to content

Commit

Permalink
update Typography color prop script and test
Browse files Browse the repository at this point in the history
  • Loading branch information
DarhkVoyd committed Sep 20, 2023
1 parent bf4d816 commit 12f5d96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/mui-material/src/Typography/Typography.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,13 @@ describe('<Typography />', () => {
marginBottom: '16px',
});
});

it('should check for invalid color value', () => {
const { container, debug } = render(
<Typography variant="h6" color="background">
Hello
</Typography>,
);
debug(container);
});
});
8 changes: 8 additions & 0 deletions packages/mui-system/src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 12f5d96

Please sign in to comment.