Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty CSS value not ignored in inline styles #186

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function styleObjToCss(s) {
let str = '';
for (let prop in s) {
let val = s[prop];
if (val != null) {
if (val != null && val !== '') {
if (str) str += ' ';
// str += jsToCss(prop);
str +=
Expand Down
7 changes: 7 additions & 0 deletions test/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ describe('render', () => {
expect(rendered).to.equal(expected);
});

it('should ignore empty css value', () => {
let rendered = render(<div style={{ color: '' }} />);
let expected = `<div></div>`;

expect(rendered).to.equal(expected);
});

it('should render SVG elements', () => {
let rendered = render(
<svg>
Expand Down