Commit b7bdafad authored by Boris Kocherov's avatar Boris Kocherov

return empty array [] only after user change array

parent 848e3029
...@@ -601,16 +601,22 @@ ...@@ -601,16 +601,22 @@
function render_array(gadget, schema, json_document, div_input, path, schema_path) { function render_array(gadget, schema, json_document, div_input, path, schema_path) {
var input, var input,
minItems = schema.minItems || 0; minItems = schema.minItems || 0;
if (schema.default === undefined &&
json_document === undefined) {
div_input.setAttribute("data-undefined", "true");
}
function element_append(child) { function element_append(child) {
if (child) { if (child) {
input.parentNode.insertBefore(child, input); input.parentNode.insertBefore(child, input);
div_input.removeAttribute("data-undefined");
} }
} }
function div_append(child) { function div_append(child) {
if (child) { if (child) {
div_input.appendChild(child); div_input.appendChild(child);
div_input.removeAttribute("data-undefined");
} }
} }
...@@ -1370,7 +1376,8 @@ ...@@ -1370,7 +1376,8 @@
array = options.arrays[path] array = options.arrays[path]
.querySelectorAll("div[data-gadget-parent-scope='" + g.element.getAttribute("data-gadget-scope") + "']"); .querySelectorAll("div[data-gadget-parent-scope='" + g.element.getAttribute("data-gadget-scope") + "']");
len = array.length; len = array.length;
if (len === 0) { if (len === 0 &&
!options.arrays[path].hasAttribute('data-undefined')) {
convertOnMultiLevel(multi_level_dict, path.slice(0, -1), []); convertOnMultiLevel(multi_level_dict, path.slice(0, -1), []);
} }
for (i = 0; i < len; i = i + 1) { for (i = 0; i < len; i = i + 1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment