Skip to content

Commit 9e37666

Browse files
committed
cloudweb-5925: abort FileReader only when readyState==LOADING
1 parent 963ab1c commit 9e37666

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

dist/FileAPI.html5.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@
139139
_rdata = /^data:[^,]+,/,
140140

141141
_toString = {}.toString,
142+
_supportConsoleLog,
143+
_supportConsoleLogApply,
142144

143145

144146
Math = window.Math,
@@ -343,8 +345,8 @@
343345
},
344346

345347
log: function (){
346-
if( api.debug && window.console && console.log ){
347-
if( console.log.apply ){
348+
if( api.debug && _supportConsoleLog ){
349+
if( _supportConsoleLogApply ){
348350
console.log.apply(console, arguments);
349351
}
350352
else {
@@ -1610,7 +1612,9 @@
16101612
_one(reader, _readerEvents, function (evt){
16111613
var isFile = evt.type != 'error';
16121614
if( isFile ){
1613-
reader.abort();
1615+
if ( reader.readyState == void 0 || reader.readyState === 1 /*LOADING*/ ) {
1616+
reader.abort();
1617+
}
16141618
callback(isFile);
16151619
}
16161620
else {
@@ -1887,7 +1891,13 @@
18871891
});
18881892

18891893

1890-
// @configuration
1894+
// Configuration
1895+
try {
1896+
_supportConsoleLog = !!console.log;
1897+
_supportConsoleLogApply = !!console.log.apply;
1898+
}
1899+
catch (err) {}
1900+
18911901
if( !api.flashUrl ){ api.flashUrl = api.staticPath + 'FileAPI.flash.swf'; }
18921902
if( !api.flashImageUrl ){ api.flashImageUrl = api.staticPath + 'FileAPI.flash.image.swf'; }
18931903
if( !api.flashWebcamUrl ){ api.flashWebcamUrl = api.staticPath + 'FileAPI.flash.camera.swf'; }

dist/FileAPI.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@
139139
_rdata = /^data:[^,]+,/,
140140

141141
_toString = {}.toString,
142+
_supportConsoleLog,
143+
_supportConsoleLogApply,
142144

143145

144146
Math = window.Math,
@@ -343,8 +345,8 @@
343345
},
344346

345347
log: function (){
346-
if( api.debug && window.console && console.log ){
347-
if( console.log.apply ){
348+
if( api.debug && _supportConsoleLog ){
349+
if( _supportConsoleLogApply ){
348350
console.log.apply(console, arguments);
349351
}
350352
else {
@@ -1610,7 +1612,9 @@
16101612
_one(reader, _readerEvents, function (evt){
16111613
var isFile = evt.type != 'error';
16121614
if( isFile ){
1613-
reader.abort();
1615+
if ( reader.readyState == void 0 || reader.readyState === 1 /*LOADING*/ ) {
1616+
reader.abort();
1617+
}
16141618
callback(isFile);
16151619
}
16161620
else {
@@ -1887,7 +1891,13 @@
18871891
});
18881892

18891893

1890-
// @configuration
1894+
// Configuration
1895+
try {
1896+
_supportConsoleLog = !!console.log;
1897+
_supportConsoleLogApply = !!console.log.apply;
1898+
}
1899+
catch (err) {}
1900+
18911901
if( !api.flashUrl ){ api.flashUrl = api.staticPath + 'FileAPI.flash.swf'; }
18921902
if( !api.flashImageUrl ){ api.flashImageUrl = api.staticPath + 'FileAPI.flash.image.swf'; }
18931903
if( !api.flashWebcamUrl ){ api.flashWebcamUrl = api.staticPath + 'FileAPI.flash.camera.swf'; }

lib/FileAPI.core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,9 @@
15181518
_one(reader, _readerEvents, function (evt){
15191519
var isFile = evt.type != 'error';
15201520
if( isFile ){
1521-
reader.abort();
1521+
if ( reader.readyState == void 0 || reader.readyState === 1 /*LOADING*/ ) {
1522+
reader.abort();
1523+
}
15221524
callback(isFile);
15231525
}
15241526
else {

0 commit comments

Comments
 (0)