export default function patchBreakElements(doc) {
  // This is a workaround to handle HTML converted from DraftJS that
  // `<div><span><br /></span><div>` becomes `<p><br /><br /></p>`.
  // Block with single `<br />` inside should be collapsed into `<p />`.
  var selector = 'div > span:only-child > br:only-child';
  Array.from(doc.querySelectorAll(selector)).forEach(patchBreakElement);
}
function patchBreakElement(brElement) {
  var _brElement$parentElem, _div$parentElement;
  var ownerDocument = brElement.ownerDocument,
    parentElement = brElement.parentElement;
  if (!ownerDocument || !parentElement) {
    return;
  }
  var div = (_brElement$parentElem = brElement.parentElement) === null || _brElement$parentElem === void 0 ? void 0 : _brElement$parentElem.parentElement;
  if (!div) {
    return;
  }
  var pp = ownerDocument.createElement('p');
  (_div$parentElement = div.parentElement) === null || _div$parentElement === void 0 || _div$parentElement.replaceChild(pp, div);
}