From cd48f05597bbb116d553ca1f1150b22dd77caf31 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 10 Jul 2019 16:49:31 +0200 Subject: [PATCH] Remove the `data-pdfjsprinting` attribute on the `` when destroying `FirefoxPrintService`/`PDFPrintService` instances (issue 10948) Also, cleans up variable definitions slightly in the `FirefoxPrintService.layout` method. --- web/firefox_print_service.js | 13 ++++++++----- web/pdf_print_service.js | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/web/firefox_print_service.js b/web/firefox_print_service.js index 14ee98d3c5459..4f267a0af3675 100644 --- a/web/firefox_print_service.js +++ b/web/firefox_print_service.js @@ -77,18 +77,21 @@ function FirefoxPrintService(pdfDocument, pagesOverview, printContainer) { FirefoxPrintService.prototype = { layout() { - let pdfDocument = this.pdfDocument; - let printContainer = this.printContainer; - let body = document.querySelector('body'); + const { pdfDocument, pagesOverview, printContainer, } = this; + + const body = document.querySelector('body'); body.setAttribute('data-pdfjsprinting', true); - for (let i = 0, ii = this.pagesOverview.length; i < ii; ++i) { - composePage(pdfDocument, i + 1, this.pagesOverview[i], printContainer); + for (let i = 0, ii = pagesOverview.length; i < ii; ++i) { + composePage(pdfDocument, i + 1, pagesOverview[i], printContainer); } }, destroy() { this.printContainer.textContent = ''; + + const body = document.querySelector('body'); + body.removeAttribute('data-pdfjsprinting'); }, }; diff --git a/web/pdf_print_service.js b/web/pdf_print_service.js index b8de6e274ac20..8eb21fb6677cd 100644 --- a/web/pdf_print_service.js +++ b/web/pdf_print_service.js @@ -74,7 +74,7 @@ PDFPrintService.prototype = { layout() { this.throwIfInactive(); - let body = document.querySelector('body'); + const body = document.querySelector('body'); body.setAttribute('data-pdfjsprinting', true); let hasEqualPageSizes = this.pagesOverview.every(function(size) { @@ -114,6 +114,10 @@ PDFPrintService.prototype = { return; } this.printContainer.textContent = ''; + + const body = document.querySelector('body'); + body.removeAttribute('data-pdfjsprinting'); + if (this.pageStyleSheet) { this.pageStyleSheet.remove(); this.pageStyleSheet = null;