From 4cd5a24899c468d3cd7b256f98af03a010b41d74 Mon Sep 17 00:00:00 2001 From: Kevin Chappell Date: Tue, 26 Nov 2024 11:14:58 -0800 Subject: [PATCH] fix: uncaught error when elements not defined resolves #377 --- src/lib/js/renderer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/js/renderer.js b/src/lib/js/renderer.js index 0a5bdfbd..d0704aed 100644 --- a/src/lib/js/renderer.js +++ b/src/lib/js/renderer.js @@ -7,14 +7,15 @@ import { parseData } from './common/utils/index.mjs' const RENDER_PREFIX = 'f-' -const processOptions = ({ editorContainer, renderContainer, ...opts }) => { - const containerLookup = container => (typeof container === 'string' ? document.querySelector(container) : container) +const containerLookup = container => (typeof container === 'string' ? document.querySelector(container) : container) +const processOptions = ({ editorContainer, renderContainer, formData, ...opts }) => { const processedOptions = { renderContainer: containerLookup(renderContainer), editorContainer: containerLookup(editorContainer), + formData: parseData(formData) || {}, } - return { ...opts, ...processedOptions } + return { elements: {}, ...opts, ...processedOptions } } const baseId = id => { @@ -39,7 +40,7 @@ const createRemoveButton = () => export default class FormeoRenderer { constructor(opts, formDataArg) { - const { renderContainer, external, elements, formData = {} } = processOptions(opts) + const { renderContainer, external, elements, formData } = processOptions(opts) this.container = renderContainer this.form = parseData(formDataArg || formData) this.external = external