Skip to content

Commit

Permalink
fix(formRender): error when destrtcuring null
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Nov 19, 2018
1 parent d24b492 commit 0b958af
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/js/form-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,28 @@ class FormRender {
className: 'rendered-form',
})
this.appendChild(renderedFormWrap)

fields.forEach(field => {
// Determine if rows are being used. If so, create the row and append to its row-{group}
// If the fields have row-, create & append to the appropriate row
const [ rowGroup ] = field.className.match(/row-([^\s]+)/)
if(rowGroup){
const rowID = this.id ? `${this.id}-row-${rowGroup}` : `row-${rowGroup}`;

// Check if this rowID is created yet or not.
let rowGroupNode = document.getElementById(rowID);
if(!rowGroupNode){
rowGroupNode = utils.markup('div', null, { id: rowID, className: 'row form-inline' });
const [rowGroup] = field.className.match(/row-([^\s]+)/) || []
if (rowGroup) {
const rowID = this.id ? `${this.id}-row-${rowGroup}` : `row-${rowGroup}`

// Check if this rowID is created yet or not.
let rowGroupNode = document.getElementById(rowID)
if (!rowGroupNode) {
rowGroupNode = utils.markup('div', null, { id: rowID, className: 'row form-inline' })
renderedFormWrap.appendChild(rowGroupNode)
}
rowGroupNode.appendChild(field);
}
else{
// Append without row
rowGroupNode.appendChild(field)
} else {
// Append without row
renderedFormWrap.appendChild(field)
}

field.dispatchEvent(events.fieldRendered)
field.dispatchEvent(events.fieldRendered)
})

}
}

Expand Down

0 comments on commit 0b958af

Please sign in to comment.