Skip to content

Commit ba82d1c

Browse files
committed
deal with empty array/objs
rather than rendering an empty ul, just render the opening and closing brackets
1 parent 5091ae8 commit ba82d1c

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

jsontree.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,17 @@ var JSONTree = (function() { // eslint-disable-line no-unused-vars
124124
};
125125

126126
var _collection = function(opening, data, closing) {
127-
return [
128-
opening,
129-
'<ul class="jstList">',
130-
data,
131-
'</ul>',
132-
closing,
133-
].join('');
127+
if (data.length > 0) {
128+
return [
129+
opening,
130+
'<ul class="jstList">',
131+
data,
132+
'</ul>',
133+
closing,
134+
].join('');
135+
} else {
136+
return opening + closing;
137+
}
134138
};
135139

136140
var _jsArr = function(array) {

tests/jsontree.tests.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)