-
Bug
-
Resolution: Fixed
-
Normal
-
9.0.0, 9.5.1
-
Security Level: Jimmy
Steps to Reproduce
same as #ZK-4754
_loadPdf(src: string) { this._destroyPdf(); PDFJS.getDocument(src).promise.then(pdf => { let pageCount = pdf.numPages, pageCountLabel = '' + pageCount; this._pdf = pdf; this._pageCount = pageCount; this._getPage(this._getDisplayedPageNumber(), true); (this.$n('toolbar-page-active') as HTMLInputElement).max = pageCountLabel; this.$n('toolbar-page-total').textContent = pageCountLabel; this._updateToolbar(); }, err => { zk.error(err.message); this._destroyPdf(); this._cleanContent(); }); },
Current Result
1 Errors Cannot read property 'style' of undefined zkex.pdfviewer.wpd:652 Uncaught (in promise) TypeError: Cannot set property 'max' of undefined at zkex.pdfviewer.wpd:652 (anonymous) @ zkex.pdfviewer.wpd:652 Promise.then (async) _loadPdf @ zkex.pdfviewer.wpd:652 bind_ @ zkex.pdfviewer.wpd:652 bindChildren_ @ zk.wpd:503 bind_ @ zk.wpd:502 bind @ zk.wpd:501 replaceChildHTML_ @ zk.wpd:497 replaceHTML @ zk.wpd:494 p @ zk.wpd:571 r @ zk.wpd:570 d @ zk.wpd:562 _zkf @ zk.wpd:563 (anonymous) @ zkex.pdfviewer.wpd:665 d @ zk.wpd:562 _zkf @ zk.wpd:563 (anonymous) @ zkex.pdfviewer.wpd:665
Expected Result
No error
Debug Information
during:
_loadPdf(src: string) { this._destroyPdf(); PDFJS.getDocument(src).promise.then(pdf => { let pageCount = pdf.numPages, pageCountLabel = '' + pageCount; this._pdf = pdf; this._pageCount = pageCount; this._getPage(this._getDisplayedPageNumber(), true); (this.$n('toolbar-page-active') as HTMLInputElement).max = pageCountLabel; this.$n('toolbar-page-total').textContent = pageCountLabel; this._updateToolbar(); }, err => { zk.error(err.message); this._destroyPdf(); this._cleanContent(); }); },
The promise callback can be reached when the component has already been detached.
this cause this.$n('toolbar-page-active') and this.$n('toolbar-page-total') to return null, cause error.
Workaround
- relates to
-
ZK-4754 JavaScript error when PDF Viewer is closed while it's loading a huge page
- Closed