brodycj / hyperapp-rewrite-demo-on-inferno-and-superfine

1 stars 0 forks source link

Missing container argument #3

Closed rbiggs closed 6 years ago

rbiggs commented 6 years ago

The function startViewRenderUltradom should have an argument for container the way app does in Hyperapp and patch does in Ultradom. Otherwise, the way it is now it only appends the view to the body tag. If no container is provided you could default to document.body. And you could be a little nice to users by letting them use a query selector to indicate the container:

function startViewRenderUltradom(initState, actions, view, container) {
   if (container && typeof container === 'string') container = document.querySelector(container)
   else if (!container) container = document.body

  // Later, append view to container:
  container.appendChild(myViewState.element)
}

With this change, you can get your example to render inside the div with id of root as in your example:

startViewRenderUltradom(initState, actions, myview, '#root')
brodycj commented 6 years ago

Thanks @rbiggs for reporting, hoping to fix this one soon.