Skip to content

Commit

Permalink
Start progress event callbacks off as null instead of empty functions.
Browse files Browse the repository at this point in the history
- Apparently some libraries will null them out in certain circumstances,
  so make sure we handle it by default.

Fix #85
  • Loading branch information
slackersoft committed Nov 7, 2014
1 parent 711764e commit a1c2859
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 42 deletions.
29 changes: 8 additions & 21 deletions lib/mock-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ getJasmineRequireObj().AjaxFakeRequest = function() {

function wrapProgressEvent(xhr, eventName) {
return function() {
xhr[eventName]();
xhr[eventName] && xhr[eventName]();
};
}

Expand Down Expand Up @@ -176,26 +176,13 @@ getJasmineRequireObj().AjaxFakeRequest = function() {

readyState: 0,

onloadstart: function() {
},

onprogress: function() {
},

onabort: function() {
},

onerror: function() {
},

onload: function() {
},

ontimeout: function() {
},

onloadend: function() {
},
onloadstart: null,
onprogress: null,
onabort: null,
onerror: null,
onload: null,
ontimeout: null,
onloadend: null,

onreadystatechange: function(isTimeout) {
},
Expand Down
29 changes: 8 additions & 21 deletions src/fakeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ getJasmineRequireObj().AjaxFakeRequest = function() {

function wrapProgressEvent(xhr, eventName) {
return function() {
xhr[eventName]();
xhr[eventName] && xhr[eventName]();
};
}

Expand Down Expand Up @@ -131,26 +131,13 @@ getJasmineRequireObj().AjaxFakeRequest = function() {

readyState: 0,

onloadstart: function() {
},

onprogress: function() {
},

onabort: function() {
},

onerror: function() {
},

onload: function() {
},

ontimeout: function() {
},

onloadend: function() {
},
onloadstart: null,
onprogress: null,
onabort: null,
onerror: null,
onload: null,
ontimeout: null,
onloadend: null,

onreadystatechange: function(isTimeout) {
},
Expand Down

0 comments on commit a1c2859

Please sign in to comment.