Skip to content

Commit

Permalink
fix(parser): fix case when style is empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliya-ivaniukovich committed Mar 21, 2018
1 parent 29084cf commit fa2a8b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/attributes-to-props.js
Expand Up @@ -46,7 +46,7 @@ function attributesToProps(attributes) {
}

// convert inline style to object
if (attributes.style) {
if (attributes.style != null) {
props.style = cssToJs(attributes.style);
}

Expand Down
30 changes: 30 additions & 0 deletions test/attributes-to-props.js
Expand Up @@ -187,6 +187,36 @@ describe('attributes to props helper', function() {
}
}
);

// style is null
assert.deepEqual(
attributesToProps({
style: null
}),
{
style: null
}
);

// style is undefined
assert.deepEqual(
attributesToProps({
style: undefined
}),
{
style: undefined
}
);

// style is empty string
assert.deepEqual(
attributesToProps({
style: ''
}),
{
style: {}
}
);
});

});
Expand Down

0 comments on commit fa2a8b4

Please sign in to comment.