function overlayElement(element, translation) {
  const value = translation.value;

  if (typeof value === 'string') {
    if (!reOverlay.test(value)) {
      // If the translation doesn't contain any markup skip the overlay logic.
      element.textContent = value;
    } else {
      // Else start with an inert template element and move its children into
      // `element` but such that `element`'s own children are not replaced.
      const tmpl = element.ownerDocument.createElementNS(
        'http://www.w3.org/1999/xhtml', 'template');
      tmpl.innerHTML = value;
      // Overlay the node with the DocumentFragment.
      overlay(element, tmpl.content);
    }
  }

  if (translation.attrs === null) {
    return;
  }

  for (const name in translation.attrs) {
    if (isAttrAllowed({ name }, element)) {
      element.setAttribute(name, translation.attrs[name]);
    }
  }
}
Overlay translation onto a DOM element.

@param   {Element}      element
@param   {string}       translation
@private