From 8acd5916e2f2f87afe43351b2a19587ca2bf7862 Mon Sep 17 00:00:00 2001 From: Max Wheeler Date: Thu, 17 Nov 2016 11:35:51 +1100 Subject: [PATCH] Render a value-less input if a list exists but has no content. --- lib/index.js | 4 ++++ src/index.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/index.js b/lib/index.js index 997cc28..b6b22e2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -69,6 +69,10 @@ function renderValue(name, value, path) { } function renderList(name, value, path) { + // Render an empty input for a list if it contains nothing + if (!value || value.length === 0) { + return render(name, '', path); + } return value.map(function (c) { return render([name, ''], c, path); }); diff --git a/src/index.js b/src/index.js index e74bdf9..a0e2ab9 100644 --- a/src/index.js +++ b/src/index.js @@ -55,6 +55,10 @@ function renderValue (name, value, path) { } function renderList (name, value, path) { + // Render an empty input for a list if it contains nothing + if (!value || value.length === 0) { + return render(name, '', path) + } return value.map((c) => { return render([name, ''], c, path) })