fix: bad error passing webContents.print(null) (#38612)

fix: bad error passing webContents.print(null)
This commit is contained in:
Shelley Vohr 2023-06-07 19:18:26 +02:00 committed by GitHub
parent 86824c070e
commit c5972ba43c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -335,12 +335,11 @@ WebContents.prototype.printToPDF = async function (options) {
}
};
WebContents.prototype.print = function (options: ElectronInternal.WebContentsPrintOptions = {}, callback) {
// TODO(codebytere): deduplicate argument sanitization by moving rest of
// print param logic into new file shared between printToPDF and print
if (typeof options === 'object') {
// Optionally set size for PDF.
if (options.pageSize !== undefined) {
// TODO(codebytere): deduplicate argument sanitization by moving rest of
// print param logic into new file shared between printToPDF and print
WebContents.prototype.print = function (printOptions: ElectronInternal.WebContentsPrintOptions, callback) {
const options = printOptions ?? {};
if (options.pageSize) {
const pageSize = options.pageSize;
if (typeof pageSize === 'object') {
if (!pageSize.height || !pageSize.width) {
@ -366,7 +365,6 @@ WebContents.prototype.print = function (options: ElectronInternal.WebContentsPri
throw new Error(`Unsupported pageSize: ${pageSize}`);
}
}
}
if (this._print) {
if (callback) {