diff --git a/src/com.elgato.template.sdPlugin/libs/js/utils.js b/src/com.elgato.template.sdPlugin/libs/js/utils.js index ba01b70..45a02f5 100644 --- a/src/com.elgato.template.sdPlugin/libs/js/utils.js +++ b/src/com.elgato.template.sdPlugin/libs/js/utils.js @@ -38,6 +38,10 @@ class Utils { * @param {Element | string} form */ static setFormValue(jsn, form) { + if (!jsn) { + return; + } + if (typeof form === 'string') { form = document.querySelector(form); } @@ -52,9 +56,11 @@ class Utils { .filter((element) => element?.name) .forEach((element) => { const { name, type } = element; - const value = jsn[name]; + const value = name in jsn ? jsn[name] : null; const isCheckOrRadio = type === 'checkbox' || type === 'radio'; + if (value === null) return; + if (isCheckOrRadio) { const isSingle = value === element.value; if (isSingle || (Array.isArray(value) && value.includes(element.value))) {