mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix!: remove viewport resizing from ElementHandle.screenshot (#11774)
This commit is contained in:
parent
4677281877
commit
ced2235ada
@ -17,15 +17,10 @@ import type {
|
|||||||
NodeFor,
|
NodeFor,
|
||||||
} from '../common/types.js';
|
} from '../common/types.js';
|
||||||
import type {KeyInput} from '../common/USKeyboardLayout.js';
|
import type {KeyInput} from '../common/USKeyboardLayout.js';
|
||||||
import {
|
import {isString, withSourcePuppeteerURLIfNone} from '../common/util.js';
|
||||||
debugError,
|
|
||||||
isString,
|
|
||||||
withSourcePuppeteerURLIfNone,
|
|
||||||
} from '../common/util.js';
|
|
||||||
import {assert} from '../util/assert.js';
|
import {assert} from '../util/assert.js';
|
||||||
import {AsyncIterableUtil} from '../util/AsyncIterableUtil.js';
|
import {AsyncIterableUtil} from '../util/AsyncIterableUtil.js';
|
||||||
import {throwIfDisposed} from '../util/decorators.js';
|
import {throwIfDisposed} from '../util/decorators.js';
|
||||||
import {AsyncDisposableStack} from '../util/disposable.js';
|
|
||||||
|
|
||||||
import {_isElementHandle} from './ElementHandleSymbol.js';
|
import {_isElementHandle} from './ElementHandleSymbol.js';
|
||||||
import type {
|
import type {
|
||||||
@ -1346,30 +1341,6 @@ export abstract class ElementHandle<
|
|||||||
|
|
||||||
const page = this.frame.page();
|
const page = this.frame.page();
|
||||||
|
|
||||||
// If the element is larger than the viewport, `captureBeyondViewport` will
|
|
||||||
// _not_ affect element rendering, so we need to adjust the viewport to
|
|
||||||
// properly render the element.
|
|
||||||
const viewport = page.viewport() ?? {
|
|
||||||
width: clip.width,
|
|
||||||
height: clip.height,
|
|
||||||
};
|
|
||||||
await using stack = new AsyncDisposableStack();
|
|
||||||
if (clip.width > viewport.width || clip.height > viewport.height) {
|
|
||||||
await this.frame.page().setViewport({
|
|
||||||
...viewport,
|
|
||||||
width: Math.max(viewport.width, Math.ceil(clip.width)),
|
|
||||||
height: Math.max(viewport.height, Math.ceil(clip.height)),
|
|
||||||
});
|
|
||||||
|
|
||||||
stack.defer(async () => {
|
|
||||||
try {
|
|
||||||
await this.frame.page().setViewport(viewport);
|
|
||||||
} catch (error) {
|
|
||||||
debugError(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only scroll the element into view if the user wants it.
|
// Only scroll the element into view if the user wants it.
|
||||||
if (scrollIntoView) {
|
if (scrollIntoView) {
|
||||||
await this.scrollIntoViewIfNeeded();
|
await this.scrollIntoViewIfNeeded();
|
||||||
|
Loading…
Reference in New Issue
Block a user