From 96fb0c0370cb31af271f49c72e905535f86019e3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 14 Aug 2017 12:34:24 +0200 Subject: [PATCH] Call the `reset()` methods in the `PDFAttachmentViewer` and `PDFOutlineViewer` constructors Rather than duplicating initialization code, we can just call `this.reset()` instead (which is also similar to other existing code, e.g. `PDFViewer`). This will also help ensure that the DOM is completely reset, before any outline items or attachments are displayed. --- web/pdf_attachment_viewer.js | 5 ++--- web/pdf_outline_viewer.js | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/web/pdf_attachment_viewer.js b/web/pdf_attachment_viewer.js index eb4a3034b..8223cbd4a 100644 --- a/web/pdf_attachment_viewer.js +++ b/web/pdf_attachment_viewer.js @@ -35,13 +35,12 @@ class PDFAttachmentViewer { * @param {PDFAttachmentViewerOptions} options */ constructor({ container, eventBus, downloadManager, }) { - this.attachments = null; - this.container = container; this.eventBus = eventBus; this.downloadManager = downloadManager; - this._renderedCapability = createPromiseCapability(); + this.reset(); + this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this)); } diff --git a/web/pdf_outline_viewer.js b/web/pdf_outline_viewer.js index 18d21471a..7aee5b626 100644 --- a/web/pdf_outline_viewer.js +++ b/web/pdf_outline_viewer.js @@ -36,12 +36,11 @@ class PDFOutlineViewer { * @param {PDFOutlineViewerOptions} options */ constructor({ container, linkService, eventBus, }) { - this.outline = null; - this.lastToggleIsShow = true; - this.container = container; this.linkService = linkService; this.eventBus = eventBus; + + this.reset(); } reset() {