fix: natural sizes for images with srcset (#2622)

This commit is contained in:
Niklas von Hertzen
2021-08-02 18:27:03 +08:00
committed by GitHub
parent 7d788c6f3d
commit 96e23d1851
2 changed files with 12 additions and 2 deletions

View File

@@ -132,8 +132,15 @@ export class DocumentCloner {
}
const clone = node.cloneNode(false) as T;
if (isImageElement(clone) && clone.loading === 'lazy') {
clone.loading = 'eager';
if (isImageElement(clone)) {
if (isImageElement(node) && node.currentSrc && node.currentSrc !== node.src) {
clone.src = node.currentSrc;
clone.srcset = '';
}
if (clone.loading === 'lazy') {
clone.loading = 'eager';
}
}
return clone;