mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-04 09:11:01 +02:00
[api-major] Remove the PDFDocumentProxy.prototype.destroy method
This is a left-over from very old code, which pre-dates the introduction of the `PDFDocumentLoadingTask` and it's nothing more than an alias for its `destroy` method. Given that `PDFDocumentProxy` already provides a way to access the underlying `PDFDocumentLoadingTask` instance, it shouldn't be necessary to have an alias for one of its methods. *Please note:* For any existing code relying on the removed method, updating it should be as simple as replacing `pdfDocument.destroy()` with `pdfDocument.loadingTask.destroy()`. --- [1] If the `PDFDocumentProxy` class was added today, there's no chance that it'd include a `destroy` method.
This commit is contained in:
parent
2e7a2215e3
commit
43ce1bb491
@ -1026,13 +1026,6 @@ class PDFDocumentProxy {
|
||||
return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the current document instance and terminates the worker.
|
||||
*/
|
||||
destroy() {
|
||||
return this.loadingTask.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {RefProxy} ref - The page reference.
|
||||
* @returns {number | null} The page number, if it's cached.
|
||||
|
||||
@ -969,7 +969,7 @@ class Driver {
|
||||
// Wipe out the link to the pdfdoc so it can be GC'ed.
|
||||
for (const task of [this.currentTask, ...this.taskQueue]) {
|
||||
if (task?.pdfDoc) {
|
||||
destroyedPromises.push(task.pdfDoc.destroy());
|
||||
destroyedPromises.push(task.pdfDoc.loadingTask.destroy());
|
||||
delete task.pdfDoc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3203,7 +3203,7 @@ describe("api", function () {
|
||||
params.url = url.href;
|
||||
loadingTask = getDocument(params);
|
||||
return loadingTask.promise
|
||||
.then(pdf => pdf.destroy())
|
||||
.then(() => loadingTask.destroy())
|
||||
.then(
|
||||
function () {
|
||||
expect(expectSuccess).toEqual(true);
|
||||
|
||||
@ -95,7 +95,7 @@ async function openDocument(source, name) {
|
||||
|
||||
if (pdfDoc) {
|
||||
pageView.reset();
|
||||
await pdfDoc.destroy();
|
||||
await pdfDoc.loadingTask.destroy();
|
||||
pdfDoc = null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user