Commit 8260b650 authored by Tristan Cavelier's avatar Tristan Cavelier

EventTarget listener assigners replaced by addEventListener method

To avoid sinon bug: fake server responds twice
parent 5f29f8dd
...@@ -311,9 +311,9 @@ exports.util.makeBinaryStringDigest = makeBinaryStringDigest; ...@@ -311,9 +311,9 @@ exports.util.makeBinaryStringDigest = makeBinaryStringDigest;
function readBlobAsBinaryString(blob) { function readBlobAsBinaryString(blob) {
var deferred = new Deferred(), fr = new FileReader(); var deferred = new Deferred(), fr = new FileReader();
fr.onload = deferred.resolve.bind(deferred); fr.addEventListener("load", deferred.resolve.bind(deferred));
fr.onerror = deferred.reject.bind(deferred); fr.addEventListener("error", deferred.reject.bind(deferred));
fr.onprogress = deferred.notify.bind(deferred); fr.addEventListener("progress", deferred.notify.bind(deferred));
fr.readAsBinaryString(blob); fr.readAsBinaryString(blob);
return deferred.promise; return deferred.promise;
} }
...@@ -321,9 +321,9 @@ exports.util.readBlobAsBinaryString = readBlobAsBinaryString; ...@@ -321,9 +321,9 @@ exports.util.readBlobAsBinaryString = readBlobAsBinaryString;
function readBlobAsArrayBuffer(blob) { function readBlobAsArrayBuffer(blob) {
var deferred = new Deferred(), fr = new FileReader(); var deferred = new Deferred(), fr = new FileReader();
fr.onload = deferred.resolve.bind(deferred); fr.addEventListener("load", deferred.resolve.bind(deferred));
fr.onerror = deferred.reject.bind(deferred); fr.addEventListener("error", deferred.reject.bind(deferred));
fr.onprogress = deferred.notify.bind(deferred); fr.addEventListener("progress", deferred.notify.bind(deferred));
fr.readAsArrayBuffer(blob); fr.readAsArrayBuffer(blob);
return deferred.promise; return deferred.promise;
} }
...@@ -331,9 +331,9 @@ exports.util.readBlobAsArrayBuffer = readBlobAsArrayBuffer; ...@@ -331,9 +331,9 @@ exports.util.readBlobAsArrayBuffer = readBlobAsArrayBuffer;
function readBlobAsText(blob) { function readBlobAsText(blob) {
var deferred = new Deferred(), fr = new FileReader(); var deferred = new Deferred(), fr = new FileReader();
fr.onload = deferred.resolve.bind(deferred); fr.addEventListener("load", deferred.resolve.bind(deferred));
fr.onerror = deferred.reject.bind(deferred); fr.addEventListener("error", deferred.reject.bind(deferred));
fr.onprogress = deferred.notify.bind(deferred); fr.addEventListener("progress", deferred.notify.bind(deferred));
fr.readAsText(blob); fr.readAsText(blob);
return deferred.promise; return deferred.promise;
} }
...@@ -365,14 +365,14 @@ function ajax(param) { ...@@ -365,14 +365,14 @@ function ajax(param) {
} }
} }
} }
xhr.onload = function (e) { xhr.addEventListener("load", function (e) {
if (e.target.status >= 400) { if (e.target.status >= 400) {
return deferred.reject(e); return deferred.reject(e);
} }
deferred.resolve(e); deferred.resolve(e);
}; });
xhr.onerror = deferred.reject.bind(deferred); xhr.addEventListener("error", deferred.reject.bind(deferred));
xhr.onprogress = deferred.notify.bind(deferred); xhr.addEventListener("progress", deferred.notify.bind(deferred));
if (typeof param.beforeSend === 'function') { if (typeof param.beforeSend === 'function') {
param.beforeSend(xhr); param.beforeSend(xhr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment