mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
Prevent the error callback from being called twice
This commit is contained in:
parent
2965bad38c
commit
813b5e78b0
1 changed files with 7 additions and 2 deletions
|
@ -52,8 +52,12 @@ function getPdf(arg, callback) {
|
|||
if ('progress' in params)
|
||||
xhr.onprogress = params.progress || undefined;
|
||||
|
||||
if ('error' in params)
|
||||
var calledErrorBack = false;
|
||||
|
||||
if ('error' in params && !calledErrorBack) {
|
||||
calledErrorBack = true;
|
||||
xhr.onerror = params.error || undefined;
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = function getPdfOnreadystatechange(e) {
|
||||
if (xhr.readyState === 4) {
|
||||
|
@ -61,7 +65,8 @@ function getPdf(arg, callback) {
|
|||
var data = (xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
||||
xhr.responseArrayBuffer || xhr.response);
|
||||
callback(data);
|
||||
} else if (params.error) {
|
||||
} else if (params.error && !calledErrorBack) {
|
||||
calledErrorBack = true;
|
||||
params.error(e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue