Skip to content

Commit fa2a8b4

Browse files
fix(parser): fix case when style is empty string
1 parent 29084cf commit fa2a8b4

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/attributes-to-props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function attributesToProps(attributes) {
4646
}
4747

4848
// convert inline style to object
49-
if (attributes.style) {
49+
if (attributes.style != null) {
5050
props.style = cssToJs(attributes.style);
5151
}
5252

test/attributes-to-props.js

+30
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,36 @@ describe('attributes to props helper', function() {
187187
}
188188
}
189189
);
190+
191+
// style is null
192+
assert.deepEqual(
193+
attributesToProps({
194+
style: null
195+
}),
196+
{
197+
style: null
198+
}
199+
);
200+
201+
// style is undefined
202+
assert.deepEqual(
203+
attributesToProps({
204+
style: undefined
205+
}),
206+
{
207+
style: undefined
208+
}
209+
);
210+
211+
// style is empty string
212+
assert.deepEqual(
213+
attributesToProps({
214+
style: ''
215+
}),
216+
{
217+
style: {}
218+
}
219+
);
190220
});
191221

192222
});

0 commit comments

Comments
 (0)