Skip to content

Commit

Permalink
Aborting of fetchPromise basicly like w3c/ServiceWorker#625.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrowe committed Mar 7, 2015
1 parent 9d2b99b commit bf5d58b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@

Request.prototype.fetch = function() {
var self = this
var xhr = new XMLHttpRequest()

return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest()
var promise = new Promise(function(resolve, reject) {
if (self.credentials === 'cors') {
xhr.withCredentials = true;
}
Expand Down Expand Up @@ -315,6 +315,10 @@

xhr.send(typeof self._bodyInit === 'undefined' ? null : self._bodyInit)
})

promise.abort = xhr.abort.bind(xhr)

return promise;
}

Body.call(Request.prototype)
Expand Down

0 comments on commit bf5d58b

Please sign in to comment.