Skip to content

Commit

Permalink
accept empty string values
Browse files Browse the repository at this point in the history
  • Loading branch information
eush77 committed Jan 23, 2016
1 parent 2483e5c commit 86e2767
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function u (type, props, value) {
}

return assign({}, props, { type: String(type) },
value && (Array.isArray(value)
? { children: value }
: { value: String(value) }));
value != null && (Array.isArray(value)
? { children: value }
: { value: String(value) }));
};
6 changes: 5 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ test(function (t) {
u('subtree', { id: 2 }, [
u('node', [
u('leaf', 'leaf-1'),
u('leaf', 'leaf-2')
u('leaf', 'leaf-2'),
u('leaf', '')
]),
u('leaf', { id: 3 }, 'leaf-3')
])
Expand All @@ -33,6 +34,9 @@ test(function (t) {
}, {
type: 'leaf',
value: 'leaf-2'
}, {
type: 'leaf',
value: ''
}]
}, {
type: 'leaf',
Expand Down

0 comments on commit 86e2767

Please sign in to comment.