Skip to content

Commit 6ccb639

Browse files
Merge pull request #49 from yuliya-ivaniukovich/empty-style-fix
Fix case when style is empty string
2 parents c344883 + fa2a8b4 commit 6ccb639

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/attributes-to-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function attributesToProps(attributes) {
5353
}
5454

5555
// convert inline style to object
56-
if (attributes.style) {
56+
if (attributes.style != null) {
5757
props.style = cssToJs(attributes.style);
5858
}
5959

test/attributes-to-props.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,36 @@ describe('attributes to props helper', function() {
207207
}
208208
}
209209
);
210+
211+
// style is null
212+
assert.deepEqual(
213+
attributesToProps({
214+
style: null
215+
}),
216+
{
217+
style: null
218+
}
219+
);
220+
221+
// style is undefined
222+
assert.deepEqual(
223+
attributesToProps({
224+
style: undefined
225+
}),
226+
{
227+
style: undefined
228+
}
229+
);
230+
231+
// style is empty string
232+
assert.deepEqual(
233+
attributesToProps({
234+
style: ''
235+
}),
236+
{
237+
style: {}
238+
}
239+
);
210240
});
211241

212242
});

0 commit comments

Comments
 (0)