/**
 * Serializes a DocumentFragment into HTML string.
 *
 * If fragment contains no element nodes,
 * returns textContent to avoid encoding issues.
 */
/**
 * @param {DocumentFragment} fragment - fragment to serialize.
 * @param {Document} doc - document reference.
 * @returns {string} - Serialized string
 */
export function serializeFragment(fragment, doc) {
  var _a;
  const container = doc.createElement('div');
  container.appendChild(fragment);
  return container.children.length === 0 ? (_a = container.textContent) !== null && _a !== void 0 ? _a : '' : container.innerHTML;
}
