fix(core): update

This commit is contained in:
2021-08-17 12:54:19 +02:00
parent 344e213c41
commit d0ee536301
4 changed files with 6267 additions and 8628 deletions

View File

@ -55,7 +55,7 @@ export class SmartSSR {
if (this.options.debug) {
screenshotBuffer = await page.screenshot({
encoding: 'binary',
});
}) as Buffer;
}
await page.$eval('body', serializeFunction);

View File

@ -1,5 +1,5 @@
declare var document: Document;
export function serializeFunction(rootNode) {
export function serializeFunction(rootNode: Node) {
const uuidv4 = () => {
return 'unixxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
@ -26,7 +26,7 @@ export function serializeFunction(rootNode) {
};
const loopProtection: any[] = [];
function serializeNode(nodeArg: HTMLElement, logThis = false) {
function serializeNode(nodeArg: HTMLElement | any, logThis = false) {
if (loopProtection.includes(nodeArg)) {
return;
}
@ -45,12 +45,12 @@ export function serializeFunction(rootNode) {
// handle slot element
const slotsForMove: HTMLSlotElement[] = [];
slots.forEach((slot) => {
slots.forEach((slot: any) => {
slotsForMove.push(slot);
});
for (const slot of slotsForMove) {
const slottedLightNodesForMove = [];
const slottedLightNodesForMove: any[] = [];
slot.assignedNodes().forEach((lightNode) => slottedLightNodesForMove.push(lightNode));
slottedLightNodesForMove.forEach((lightNode) =>
slot.parentNode.insertBefore(lightNode, slot)
@ -74,7 +74,7 @@ export function serializeFunction(rootNode) {
}
}
childNodes.forEach((childNode) => {
childNodes.forEach((childNode: ChildNode) => {
if (childNode instanceof HTMLElement) {
if (childNode.tagName === 'STYLE') {
childNode.textContent = prependCss(nodeUUID, childNode.textContent);