Skip to content

Commit

Permalink
fix: uncaught error when elements not defined
Browse files Browse the repository at this point in the history
resolves #377
  • Loading branch information
kevinchappell committed Nov 26, 2024
1 parent cec4935 commit 4cd5a24
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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
Expand Down

0 comments on commit 4cd5a24

Please sign in to comment.