src/js/build-html.js
function render (selector, data) {
    var collapsed = false
    var container = createList(collapsed)

    data.forEach(function (d) {
      createEl(d, container)
    })

    var parent = document.querySelector(selector)

    // Return if no parent is found.
    if (parent === null) {
      return
    }

    // Remove existing child if it exists.
    if (parent.firstChild) {
      parent.removeChild(parent.firstChild)
    }

    // Just return the parent and don't append the list if no links are found.
    if (data.length === 0) {
      return parent
    }

    // Append the Elements that have been created
    return parent.appendChild(container)
  }
function render (selector, data) {
    var collapsed = false
    var container = createList(collapsed)

    data.forEach(function (d) {
      createEl(d, container)
    })

    var parent = document.querySelector(selector)

    // Return if no parent is found.
    if (parent === null) {
      return
    }

    // Remove existing child if it exists.
    if (parent.firstChild) {
      parent.removeChild(parent.firstChild)
    }

    // Just return the parent and don't append the list if no links are found.
    if (data.length === 0) {
      return parent
    }

    // Append the Elements that have been created
    return parent.appendChild(container)
  }
function render ( selector , data ) { var collapsed = false var container = createList ( collapsed ) data . forEach ( function ( d ) { createEl ( d , container ) } ) var parent = document . querySelector ( selector ) // Return if no parent is found. if ( parent === null ) { return } // Remove existing child if it exists. if ( parent . firstChild ) { parent . removeChild ( parent . firstChild ) } // Just return the parent and don't append the list if no links are found. if ( data . length === 0 ) { return parent } // Append the Elements that have been created return parent . appendChild ( container ) }
Render nested heading array data into a given selector.
@param {String} selector
@param {Array} data
@return {HTMLElement}
Render nested heading array data into a given selector .