function convertToElementInternal(templateResult, domHelper = undefined) {
  const dom = domHelper || googDom.getDomHelper();
  let wrapper;
  if (templateResult &&
      (/** @type {!SanitizedContent} */ (templateResult)).renderAsElement) {
    wrapper =
        (/** @type {!SanitizedContent} */ (templateResult)).renderAsElement();
  } else {
    wrapper = dom.createElement(TagName.DIV);
    const html = ensureTemplateOutputHtml(templateResult);
    assertFirstTagValid(html.getTypedStringValue());
    safe.unsafeSetInnerHtmlDoNotUseOrElse(wrapper, html);
  }

  // If the template renders as a single element, return it.
  if (wrapper.childNodes.length == 1) {
    const firstChild = wrapper.firstChild;
    if (firstChild.nodeType == NodeType.ELEMENT) {
      return /** @type {!Element} */ (firstChild);
    }
  }

  // Otherwise, return the wrapper DIV.
  return wrapper;
}
Non-strict version of `convertToElement`.
@param {*} templateResult The processed template.
@param {?googDom.DomHelper=} domHelper The DOM helper used to create DOM
    nodes; defaults to `goog.dom.getDomHelper`.
@return {!Element} Rendered template contents, wrapped in a parent DIV
    element if necessary.