Skip to content

Commit 86e2767

Browse files
committed
accept empty string values
1 parent 2483e5c commit 86e2767

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function u (type, props, value) {
1010
}
1111

1212
return assign({}, props, { type: String(type) },
13-
value && (Array.isArray(value)
14-
? { children: value }
15-
: { value: String(value) }));
13+
value != null && (Array.isArray(value)
14+
? { children: value }
15+
: { value: String(value) }));
1616
};

test/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ test(function (t) {
1111
u('subtree', { id: 2 }, [
1212
u('node', [
1313
u('leaf', 'leaf-1'),
14-
u('leaf', 'leaf-2')
14+
u('leaf', 'leaf-2'),
15+
u('leaf', '')
1516
]),
1617
u('leaf', { id: 3 }, 'leaf-3')
1718
])
@@ -33,6 +34,9 @@ test(function (t) {
3334
}, {
3435
type: 'leaf',
3536
value: 'leaf-2'
37+
}, {
38+
type: 'leaf',
39+
value: ''
3640
}]
3741
}, {
3842
type: 'leaf',

0 commit comments

Comments
 (0)