How to use the fela-tools.isValidHTMLElement function in fela-tools

To help you get started, we’ve selected a few fela-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robinweser / fela / packages / fela / src / tools / renderToElement.js View on Github external
export default function renderToElement(
  renderer: DOMRenderer,
  mountNode: DOMNode
): Function {
  // mountNode must be a valid HTML element to be able
  // to set mountNode.textContent later on
  if (!isValidHTMLElement(mountNode)) {
    throw new Error(
      'You need to specify a valid element node (mountNode.nodeType = 1) to render into.'
    )
  }

  return renderer.subscribe(() => {
    mountNode.textContent = renderToString(renderer)
  })
}