clipper(web): make ready for publishing

This commit is contained in:
Abdullah Atta
2022-11-28 16:39:57 +05:00
parent 7cd6a6e9ee
commit 47dcbba522
4 changed files with 10 additions and 11 deletions

View File

@@ -293,8 +293,10 @@ function clonePseudoElements(
}
function copyUserInput(original: HTMLElement, clone: HTMLElement) {
if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
if (original instanceof HTMLInputElement)
if (
original instanceof HTMLInputElement ||
original instanceof HTMLTextAreaElement
)
clone.setAttribute("value", original.value);
}

View File

@@ -429,10 +429,9 @@ function getElementViewportInfo(el: HTMLElement) {
}
function toDocument(head: HTMLElement, body: HTMLElement) {
const newHTMLDocument = document.implementation.createHTMLDocument();
newHTMLDocument.head.outerHTML = head.outerHTML;
newHTMLDocument.body.outerHTML = body.outerHTML;
return newHTMLDocument;
const doc = document.implementation.createHTMLDocument();
doc.documentElement.replaceChildren(head, body);
return doc;
}
function cleanup() {
@@ -475,7 +474,7 @@ async function getPage(
const head = document.createElement("head");
const title = document.createElement("title");
title.innerHTML = document.title;
title.innerText = document.title;
head.appendChild(title);
return {